Cannot create with a select has relation.

I have a two modal. Modal Brand has: public function categories() { return $this->belongsToMany(Category::class, 'brand_category', 'brand_id', 'category_id'); } Modal Category has: public function products(): { return $this->hasMany(Product::class, 'category_id', 'id'); } BrandResource has: Forms\Components\Select::make('category') ->relationship(name: 'categories', titleAttribute: 'name') ->multiple() ->searchable() ->preload() When i create a brand and choose a option from select. I have an error: General error: 1364 Field 'id' doesn't have a default value
No description
3 Replies
Dennis Koch
Dennis Koch3mo ago
id should be auto-incrementing shouldn't it?
Messenger of truth
Messenger of truthOP3mo ago
I used uuid for id And i dont create a model for brand_category table
Dennis Koch
Dennis Koch3mo ago
Makes sense that id is null then. It cannot be auto-filled by the DB. I think you need a model otherwise that column is always empty
Want results from more Discord servers?
Add your server