Fixed - MassAssignmentException in model.php laravel 5?By Hardik Savani | April 25, 2016 | | 956 Viewer | Category : Laravel
Share this post:
massassignmentexception is for the security purpose if laravel 5 function. When i did start Laravel 5 and first i did try to add user using "User::create(['name'=>'hd','password'=>'1w'])" then i found bellow error. I was thinking what was wrong, but after investigation i found it for our security purpose, because you have to add field name that you want to insert that way other Http script or hacker etc can't insert something elelse you need to add $fillable variable in your Model. So, let's see user model example.
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
* The attributes that are mass assignable.
* @var array
protected $fillable = [
'name', 'email', 'password','facebook_id'
* The attributes excluded from the model's JSON form.
* @var array
protected $hidden = [
public function dataCreate($input)
- PHP - Input multiple tags with dynamic autocomplete example
- Laravel 5 Redirect to URL using redirect() helper
- Dynamic Autocomplete search using Bootstrap Typeahead JS Example
- Laravel 5.3 - How to create SEO friendly sluggable URL
- How to solve - This cache store does not support tagging?
- PHP - How to convert HTML file to PDF using Dompdf library?
- How to add mysql trigger from migrations in Laravel 5?
- Jquery - Timepicker with AM PM Example code with demo using jQuery Timepicker Plugin