当前位置:网站首页>Action after deleting laravel's model
Action after deleting laravel's model
2022-07-01 15:59:00 【Brother Jing】
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
// use App\Models\OrderGoods;
use Illuminate\Database\Eloquent\Model;
class Order extends Model
{
use HasDateTimeFormatter;
public $primaryKey = 'order_id';
// database 'database_test' Medium test surface
public $table = 'order';
public $timestamps = false;
protected $connection = 'baixiao';
/**
* Delete
*/
public static function boot()
{
parent::boot();
static::deleted(function ($model) {
// In this way, you can get the current operation id
$order_id = $model->order_id;
if ($order_id) {
OrderGoods::where('order_id', $order_id)->delete();
}
});
}
}
After deleting the data of the order table , If we still need to delete the order item table , Can be in order In the model of , Join this
After deleting the order , Continue to delete order items
边栏推荐
- Hardware development notes (9): basic process of hardware development, making a USB to RS232 module (8): create asm1117-3.3v package library and associate principle graphic devices
- TensorFlow團隊:我們沒被拋弃
- 【LeetCode】43. String multiplication
- 2022 Moonriver全球黑客松优胜项目名单
- 最新NLP赛事实践总结!
- 远程办公经验?来一场自问自答的介绍吧~ | 社区征文
- Lean Six Sigma project counseling: centralized counseling and point-to-point counseling
- 并发编程系列之什么是ForkJoin框架?
- How to adjust the size of computer photos to what you want
- [IDM] IDM downloader installation
猜你喜欢
![[IDM] IDM downloader installation](/img/2b/baf8852b422c1c4a18e9c60de864e5.png)
[IDM] IDM downloader installation

Thinkphp内核工单系统源码商业开源版 多用户+多客服+短信+邮件通知

并发编程系列之什么是ForkJoin框架?

What is the forkjoin framework in the concurrent programming series?

GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速

【IDM】IDM下载器安装

Automatic, intelligent and visual! Deeply convinced of the eight designs behind sslo scheme

Nuxt.js数据预取

process. env. NODE_ ENV

Automatique, intelligent, visuel! Forte conviction des huit conceptions derrière la solution sslo
随机推荐
TensorFlow團隊:我們沒被拋弃
二叉树的前序,中序,后续(非递归版本)
Description | Huawei cloud store "commodity recommendation list"
Solution to the problem that the keypad light does not light up when starting up
AVL 平衡二叉搜索树
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
Stm32f411 SPI2 output error, pb15 has no pulse debugging record [finally, pb15 and pb14 were found to be short circuited]
周少剑,很少见
Win11如何設置用戶權限?Win11設置用戶權限的方法
新出生的机器狗,打滚1小时后自己掌握走路,吴恩达开山大弟子最新成果
马来西亚《星报》:在WTO MC12 孙宇晨仍在坚持数字经济梦想
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
2022-07-01日报:谷歌新研究:Minerva,用语言模型解决定量推理问题
Task.Run(), Task.Factory.StartNew() 和 New Task() 的行为不一致分析
Microservice tracking SQL (support Gorm query tracking under isto control)
Research on manually triggering automatic decision of SAP CRM organization model with ABAP code
Task. Run(), Task. Factory. Analysis of behavior inconsistency between startnew() and new task()
#夏日挑战赛# HarmonyOS canvas实现时钟
[video memory optimization] deep learning video memory optimization method
她就是那个「别人家的HR」|ONES 人物