php - MassAssignmentException in laravel5 -


i used laravel5...and want store data in database , when press submit error appeared

> massassignmentexception in c:\xampp\htdocs\marriage\vendor\laravel\framework\src\illuminate\database\eloquent\model.php line 417: _token 

my controller code

public function store(request $request) {     $custom =request::all();     custom::create($custom);      return redirect('custom');  } 

model code

class custom_table extends model {   protected $fillable=[     'skin_color',     'cast',     'residence',     'family_members',     'hieght',     'created_at',     'updated_at' ]; 

}

please me how resolve error

you running error, because request passing "_token" attribute, , not mass assignable.

you can exclude using except method, such:

public function store(request $request) {     $custom = request::except('_token'); // exclude _token attribute     custom::create($custom);      return redirect('custom');  } 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -