Closed ajiehatajie closed 7 years ago
taggable_id
can't be null because it represents a polymorphic relations table.
The issue for you is that you've created the new Post object but haven't saved it before tagging it. So the Post doesn't have an id yet that we can link in the morph table.
The easiest fix:
$requestData = $request->all();
$post = New Post($requestData);
$post->save(); // <--- ADD THIS
$post->tag([$request->input('tag')]);
this issue Integrity constraint violation: 1048 Column 'taggable_id' cannot be null
but problem is solved if column taggable_id allow null in mysql
controller store
model
thanks you