rtconner / laravel-tagging

Tag support for Laravel Eloquent models - Taggable Trait
MIT License
882 stars 168 forks source link

insert error #17

Closed sedehi closed 10 years ago

sedehi commented 10 years ago

I can not add tag Because this error was displayed

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'taggable_id' cannot be null (SQL: insert into tagging_tagged (tag_name, tag_slug, taggable_type, taggable_id) values (Navid, navid, Post, ))

Sorry for my bad English

rtconner commented 10 years ago

I suspect this is probably a bug in your own code. But please submit a unit test for me to reproduce this if it is really an issue with the library.

mor619dx commented 10 years ago

I got same problem, any solution?

frama21 commented 3 years ago

i got same issue, any update or any solution to fix this? thanks

rtconner commented 3 years ago

tell me how to reproduce it

frama21 commented 3 years ago

tell me how to reproduce it

in my case i use Lumen 8

when i create new data like this structure

$data = new Data;
$data->name = $request->name;
$data->tag($request->tags);
$data->save();

it's throw error like @sedehi tell

but if i do like this

$data = new Data;
$data->name = $request->name;
$data->save();
$data->tag($request->tags);

it's working @rtconner

rtconner commented 3 years ago

I see. I feel like the best I'll be able to do is throw a more informative exception. There is no way to save a tag for a non-created model record.