I need to add data to more than one table with belongsToMany in the project I developed with Laravel filament.
Example DB:
- Category: id, name
- Anime: id, name, description
- AnimeCategory: id, category_id, anime_id
Code:
- Anime Resource: https://codeshare.io/3AEg7v
- Anime Model: https://codeshare.io/mpydBj
- Category Model: https://codeshare.io/lorKBD
- AnimeCategory Model: https://codeshare.io/r9A3BY
I am getting categoryId not found error in Anime Table.
Found in Anime Resource:
Select::make('categoryId')
->label('Kategori seçiniz')
->placeholder('Kategori Seçiniz')
->required()
->multiple()
->options(function () {
return Category::all()->pluck('title', 'id');
}),
How can I add selected multi-category id data to AnimeCategory table?