hamilton

Experience

70

0 Best Reply Awards

  • Member Since 1 Month Ago
  • 0 Lessons Completed
  • 0 Favorites

17th September, 2018

hamilton left a reply on Add [title] To Fillable Property To Allow Mass Assignment On [App\Post]. • 4 weeks ago

Hi guys,

Thanks for your suggestions.

Turns out I working on a model of the same name but in a different but similarly named project!

I added:

protected $fillable = ['title','content'];

Then everything worked as expected.

Sorry for wasting your time.

14th September, 2018

hamilton left a reply on Add [title] To Fillable Property To Allow Mass Assignment On [App\Post]. • 1 month ago

I created the model in Terminal using:

php artisan make:model Post in Terminal

Resulting code generated:

class Post extends Model {

use SoftDeletes;

protected $dates = ['deleted_at'];
 
protected $fillable = ['title','content'];
    
public function user() {
    return $this->belongsTo('App\User');
}
 

}

hamilton started a new conversation Add [title] To Fillable Property To Allow Mass Assignment On [App\Post]. • 1 month ago

Hi Folks,

I'm new to Laravel (5.7) and trying to save to DB using Post::create()

Despite having:

protected $fillable = ['title','content'];

in the Post model when I attempt to run:

Post::create([
'title' => 'Post Title',
    'content' => 'Post Content' 
]);

I get:

"Add [title] to fillable property to allow mass assignment on [App\Post]."

I searched everywhere for solution but come up with nothing so for.

Any help appreciated. If more info required let me know.

Thanks

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.