当前位置:网站首页>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
边栏推荐
- Programming examples of stm32f1 and stm32subeide - production melody of PWM driven buzzer
- Overview | slam of laser and vision fusion
- #夏日挑战赛# HarmonyOS canvas实现时钟
- Logical analysis of automatic decision of SAP CRM organization model
- 大龄测试/开发程序员该何去何从?是否会被时代抛弃?
- 近半年内连获5家“巨头”投资,这家智能驾驶“黑马”受资本追捧
- Zhang Chi's class: several types and differences of Six Sigma data
- 你TM到底几点下班?!!!
- 开机时小键盘灯不亮的解决方案
- 微服务追踪SQL(支持Isto管控下的gorm查询追踪)
猜你喜欢
近半年内连获5家“巨头”投资,这家智能驾驶“黑马”受资本追捧
HR面试:最常见的面试问题和技巧性答复
Pnas: brain and behavior changes of social anxiety patients with empathic embarrassment
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
Win11如何设置用户权限?Win11设置用户权限的方法
你TM到底几点下班?!!!
What time do you get off work?!!!
Reading notes of top performance version 2 (V) -- file system monitoring
搜索框和按钮缩放时会有缝隙的bug
Smart Party Building: faith through time and space | 7.1 dedication
随机推荐
Zhang Chi Consulting: lead lithium battery into six sigma consulting to reduce battery capacity attenuation
【Pygame实战】你说神奇不神奇?吃豆人+切水果结合出一款你没玩过的新游戏!(附源码)
[200 opencv routines] 216 Draw polylines and polygons
Équipe tensflow: Nous ne sommes pas abandonnés
【LeetCode】43. 字符串相乘
微服务追踪SQL(支持Isto管控下的gorm查询追踪)
Pico,是要拯救还是带偏消费级VR?
【显存优化】深度学习显存优化方法
Go语学习笔记 - gorm使用 - 表增删改查 | Web框架Gin(八)
自動、智能、可視!深信服SSLO方案背後的八大設計
Zero copy technology of MySQL
一次革命、两股力量、三大环节:《工业能效提升行动计划》背后的“减碳”路线图...
Research on manually triggering automatic decision of SAP CRM organization model with ABAP code
Crypto Daily:孙宇晨在MC12上倡议用数字化技术解决全球问题
并发编程系列之什么是ForkJoin框架?
2023 spring recruitment Internship - personal interview process and face-to-face experience sharing
Some abilities can't be learned from work. Look at this article, more than 90% of peers
硬件开发笔记(九): 硬件开发基本流程,制作一个USB转RS232的模块(八):创建asm1117-3.3V封装库并关联原理图元器件
ABAP-调用Restful API
Create employee data in SAP s/4hana by importing CSV