1 $validated = $request->validated();
2
3use this:
4
5 public function createAccount(RegisterRequest $request)
6 {
7 $attr = $request->validated();
8
9instead of :
10
11 public function createAccount(Request $request)
12 {
13 $attr = $request->validate([
14 'name' => 'required|string|max:255',
15 'email' => 'required|string|email|unique:users,email',
16 'password' => 'required|string|min:6|confirmed'
17 ]);
18
19
20php artisan make:request RegisterRequest
21
22 public function rules()
23 {
24 return [
25 'name' => 'required|string|max:255',
26 'email' => 'required|string|email|unique:users,email',
27 'password' => 'required|string|min:6|confirmed'
28 ];
29 }
1/**
2 * Store a new blog post.
3 *
4 * @param Request $request
5 * @return Response
6 */
7
8public function store(Request $request)
9{
10 $validatedData = $request->validate([
11 'title' => 'required|unique:posts|max:255',
12 'body' => 'required',
13 ]);
14
15 // The blog post is valid...
16}
1 $messsages = array(
2 'email.required'=>'You cant leave Email field empty',
3 'name.required'=>'You cant leave name field empty',
4 'name.min'=>'The field has to be :min chars long',
5 );
6
7 $rules = array(
8 'email'=>'required|unique:content',
9 'name'=>'required|min:3',
10 );
11
12 $validator = Validator::make(Input::all(), $rules,$messsages);
13