0

enter image description herei have 3 tables made in Voyager and with BREAD (news - catg - news_catg). My 'news' Table have Relationship (Belongs To Many) to 'catg' and the news_catg is the pivot table Every think is working will except the Delete i have to Delete the Records manually from the pivot table it should be automatic like add and update

2 Answers2

1

finally i found that there is bug in Voyager and there is no way to fix this issue from the admin panel so i did the flowing :

1 - deleted the Pivot table .

2- create new migration file in my app

3 -

`   Schema::create('Relation table name', function (Blueprint $table) {
            $table->integer('first table id')->unsigned();
            $table->foreign('first table id')->references('id')
                  ->on('first table')->onDelete('cascade');
            $table->integer('second table id')->unsigned();
            $table->foreign('second table id')->references('id')->on('second table');
        });`

Relation table name should be like :secondtablename_firsttablename for ex : catgs_news or it wont work !!! and the first table id should be tablename_id like news_id

4- then you go to voyager and it will work but you have to edit the new table and add timestamps and you dont have to make bread for it

0

You can use the detach() function to delete data from pivot table.