Answers for "laravel file validate"

PHP
2

request validate file laravel

$validated = $request->validated();

use this:

    public function createAccount(RegisterRequest $request)
    {
        $attr = $request->validated();

instead of :

    public function createAccount(Request $request)
    {
        $attr = $request->validate([
            'name' => 'required|string|max:255',
            'email' => 'required|string|email|unique:users,email',
            'password' => 'required|string|min:6|confirmed'
        ]);


php artisan make:request RegisterRequest

    public function rules()
    {
        return [
            'name' => 'required|string|max:255',
            'email' => 'required|string|email|unique:users,email',
            'password' => 'required|string|min:6|confirmed'
        ];
    }
Posted by: Guest on September-22-2021
1

laravel validate file type

'image' => 'required|mimes:jpeg'
//or
'image' => 'required|image'
Posted by: Guest on June-23-2021

Browse Popular Code Answers by Language