1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Laravel,livewire2.0 TipsAdvent Calendar 2022

Day 5

【Laravel9】リクエストパラメータをちょびちょびキャストする時代は終わり

Last updated at Posted at 2022-12-04

概要

Laravel9から一部パラメータをキャストして取得できるようになりました

bool
$archived = $request->boolean('archived');
date
$birthday = $request->date('birthday');

//日付フォーマットも可能
$elapsed = $request->date('elapsed', '!H:i', 'Europe/Madrid');

Laravel9.32で更にキャストできる種類が増えました ← New

まだドキュメントには記載されてません

integer
$request->integer('some_int_value');
float
$request->float('some_float_value');

参考

boolとdateはドキュメントに記載されてます。

PHP8ならではの、その他Laravel9から色々追加したみたいなので覗いてみてください。

enumとか

スクリーンショット 2022-11-28 18.24.41.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?