rinvex / laravel-categories

Rinvex Categorizable is a polymorphic Laravel package, for category management. You can categorize any eloquent model with ease, and utilize the power of Nested Sets, and the awesomeness of Sluggable, and Translatable models out of the box.
MIT License
457 stars 68 forks source link

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'categorizable_id' cannot be null #101

Closed maxhacker11 closed 3 years ago

maxhacker11 commented 3 years ago

Doesn't work when I try to attach: $business->attachCategories(1);

The category exists in the categories table, it's ID is 1. I literally have no clue what's happening.

I get the following error: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'categorizable_id' cannot be null

maxhacker11 commented 3 years ago

I figured it out, holy smokes I am pissed off at myself xD This was my order:

$business->attachCategories(1);
$business->save();

It didn't work, so after using php artisan tinker and seeing that it works there, i just reversed it:

$business->save();
$business->attachCategories(1);
Omranic commented 3 years ago

Glad you got it sorted ;)