Monday, March 20, 2017

form validation not working in laravel

I am working on laravel 5.3.30 and created a profile page with form and try to validate the data when the form is submitted but I am not getting any errors after submitting the form, its just refresh the page.

Route File:

Route::get('/', function () {
    return view('main');
});

Auth::routes();

Route::get('/home', 'HomeController@index');

Route::get('logout', '\App\Http\Controllers\Auth\LoginController@logout');
Route::resource('profile','ProfileController');

Profile Form:

{!! Form::open(array('route'=>'profile.store')) !!}
    <div class="form-group">
    <span class="required">*</span>
 
        </div>
        <div class="form-group">
                                              <span class="required">*</span>
    
     </div>
     

{!! Form::close() !!}

Validation in Profile Controller:

public function store(Request $request)
    {
       $this->validate($request,array(
            'first_name'=>'required|max:255',
            'last_name'=>'required|max:255'
   ));
   }

When I submit the form without filling anything, it just refresh the page and does not show any errors. Please suggest something. Thanks in advance.



via vivek321

Advertisement