protected $fillable = ['user_id', 'url'];
Or if you have one to many relationship images() but you still need to have set $fillable in Image model
$user->images()->create(['url' => 'storage/img/user/'.$imageName]);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a database table called 'images' and a model called 'Image' but when I run
Image::create([
'user_id' => $user->id,
'url' => 'storage/img/user/'.$imageName
]);
Nothing happens. Running the next command works perfectly.
DB::table('images')->insert([
'user_id' => $user->id,
'url' => 'storage/img/user/'.$imageName
]);
Please or to participate in this conversation.