How to delete records with relationship with multiple tables

Posted 3 months ago by AbdulBazith

Guys my project has a purchase order form.

i have two tables purchase_order_table and order_list_table

both in relationship purchase_order_table is parent tble and order_list is child table.

this is my purchase_order_migration file

 Schema::create('purchase_orders', function (Blueprint $table) {

this is my order_list migration file

  Schema::create('order_lists', function (Blueprint $table) {

i didnt use the onDelete('cascade'); in the migration.

now i need to delete record from parent table which in turn must delete all the relevant child table.

how to do this??

i need few calculation also.. those are in other tables.

say for example.

if i add a product to store, say rice 40 kg 4000 rupees then it will be added to the store and also the amount will be updated to that supplier in supplier_amount table.

so when i delete the entry which i made in the store then it should less that 4000 rupees amount amount from the supplier_amount table and also the qnty from the store table.

so how i can i delete a record with relationship with multiple tables.

Kindly some one suggest your ideas please.

Please sign in or create an account to participate in this conversation.