Answers for "file validation laravel"

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
2

rule::exists with custom message laravel

$messsages = array(
		'email.required'=>'You cant leave Email field empty',
		'name.required'=>'You cant leave name field empty',
                'name.min'=>'The field has to be :min chars long',
	);

	$rules = array(
		'email'=>'required|unique:content',
		'name'=>'required|min:3',
	);

	$validator = Validator::make(Input::all(), $rules,$messsages);
Posted by: Guest on May-07-2020

Code answers related to "file validation laravel"

Browse Popular Code Answers by Language