laravel required with code example
Example 1: create form request laravel
php artisan make:request StoreBlogPost
Example 2: laravel required if
"sale_price" => "required_if:list_type,==,selling"
Example 3: laravel validation
public function store(Request $request)
{
$validatedData = $request->validate([
'title' => 'required|unique:posts|max:255',
'body' => 'required',
]);
}
Example 4: 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);
Example 5: validate field for existing client laravel
unique:users,username,id,1
Example 6: validation.required laravel
9
If it has worked for you before then you should check if you have messages defined in the app\lang\en\validation.php or by chance you have changed the locale of the app and have not defined the messages for it. There are many possibilities.