vendredi 4 décembre 2015

Laravel 5 validation is not working

My route code looks like this

Route::post('doCheckIn', 'TransactionController@store');

My store in Controller looks like this, I'm trying to do room checking in...

public function store(Request $request)
    {

        for ($x=1; $x<=$request->num; $x++)
        {
            if($request->input('guest_name'.$x) == "")
            {
                //echo 'here';
            }
            $this->validate($request, [
            'guest_name'.$x => 'required',
            'room_num'.$x => 'required',
            'check_in'.$x => 'required',
            'check_out'.$x => 'required',
            ]);
        }

As you can see there is an if statement in my store function which works perfectly fine when I comment out the this->validate to avoid compiler running it. It echoes on the page. But it won't work when I get rid of the comment and try to validate the form. Meaning the validate function doesn't even work. the page shows

MethodNotAllowedHttpException in RouteCollection.php line 219:

I tried making another laravel project and running it in a separate page and it worked. Problem is all my codes are in this project folder. I'm stuck! Anybody please help. Is there any class that I must use prior to using validate?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire