Answer the question
In order to leave comments, you need to log in
Zeroing the category_id field in the products table if the category is deleted?
Laravel oneToMany. The products table has a category_id field . At the moment, if you delete the category , then there is a check when parsing the product category, if there is such a category, display its name. However, the category_id field is still populated .
->onDelete('cascade');
// мне не надо удалять продукты если категория удалена
//костыль в функции удаления категории будет что - то в духе
DB::table('products')->where('category_id', $current_deleting_cat_id)->update(['category_id', null]));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question