DEV Community

Morcos Gad
Morcos Gad

Posted on

New Things Added - Laravel 9.22 Released

Let's get started quickly I found new things in Laravel 9.22 Released I wanted to share with you.

File validation rule object that provides a fluent interface like the Password validation rule

// Before
$request->validate([
  'file' => ['required', 'file', 'mimes:mp3,wav,aac', 'max:12287'],
  'image' => ['required', 'file', 'image', 'min:2048', 'max:12287', Rule::dimensions()->maxWidth(1000)->maxHeight(500)],
]);

// After
$request->validate([
  'file' => ['required', File::types(['mp3', 'wav', 'aac'])->smallerThan(12 * 1024)],
  'image' => ['required', File::image()->atLeast(2 * 1024)->smallerThan(12 * 1024)->dimensions(Rule::dimensions()->maxWidth(1000)->maxHeight(500))],
]);
Enter fullscreen mode Exit fullscreen mode

more details :-
https://laravel.com/docs/9.x/validation#validating-files

File::hash($path)
// 196b0f14eba66e10fba74dbf9e99c22f => default md5

File::hash($path, 'sha256')
// 19c451aedfb24c338a9a2a5c31d553ed77e7cdefc655035f390176ac24066051
Enter fullscreen mode Exit fullscreen mode
$user = User::first();
$user->type;
route('user-type', $user->type);
Enter fullscreen mode Exit fullscreen mode

I hope you enjoyed with me and to learn more about this release visit the sources and search more. I adore you who search for everything new.
Source :- https://laravel-news.com/laravel-9-22-0
Source :- https://www.youtube.com/watch?v=qiJrRKPqo3k

Oldest comments (0)