laravel 5.3 : Method [validate] does not exist.

Posted 2 years ago by amitshrestha221

Validate method doesn't work



<?php

namespace Modules\Register\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Factory;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Input;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session;
use DB;

class RegisterController extends Controller
{
    /**
     * Display a listing of the resource.
     * @return Response
     */
    public function index()
    {
        return view('register::v_register');
    }

    /**
     * Show the form for creating a new resource.
     * @return Response
     */
    public function create()
    {
        return view('register::create');
    }

    /**
     * Store a newly created resource in storage.
     * @param  Request $request
     * @return Response
     */
    public function store(Request $request)
    { 
        $this->validate($request,[
                                'email'=>'required',
                                'password'=>'required|min:6',
                                'cpassword'=>'required|same:password',
                                'role'=>'required'
                                ]);

        $register_data=array('email'=>Input::get('email'),
                                'password'=>Hash::make(Input::get('password')),
                                'is_active'=>'no',
                                'created_at'=>date('Y-d-m H:i:s')
                            );

        $registration_code=$register_data['registration_code'];
        $user_id=User::insertGetId($register_data);
        
        $role_id=Input::get('role');

        $userroles=new UserRoles;
        $userroles->userID=$user_id->id;
        $userroles->roleID=$role_id;
        $userroles->save();

        $email_data['to']=Input::get('email');
        
        $email_template=EmailTemplates::select('template')->where('id','2')->first();
        $email_data['body']=$email_template->template;
        
        $vars = array(
                    '[[SYSTEM_NAME]]' => SYSTEM_NAME,
                    '[[RESET_URL]]' => 'test.com/'.$registration_code,
                    '[[EMAIL]]' => Input::get('email')
                      );
        
        $email_data['body']=strtr($email_data['body'],$vars);
        General::sendMailFunction('register::main',$email_data,'Welcome to '.SYSTEM_NAME);

        Session::put('codeEmail',Input::get('email'));
        
        $data['titles']=Cms::select('title')->get();
        return view('register::v_register_confirm',$data);
    }


Please sign in or create an account to participate in this conversation.