first commit
This commit is contained in:
32
app/common/model/Customers(待删除).php
Normal file
32
app/common/model/Customers(待删除).php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use think\Model;
|
||||
use app\common\model\CustomerEmployees;
|
||||
|
||||
class Customers extends Model
|
||||
{
|
||||
protected $table = 'customers';
|
||||
|
||||
public function employees()
|
||||
{
|
||||
return $this->hasMany(CustomerEmployees::class, 'customer_id', 'id');
|
||||
}
|
||||
|
||||
/* 模型事件:在删除客户记录之后执行 */
|
||||
public static function onAfterDelete($customer)
|
||||
{
|
||||
// 删除与该客户相关的员工记录
|
||||
$customer->employees()->delete();
|
||||
}
|
||||
|
||||
|
||||
public function getCompanyOfAccount(){
|
||||
return $this->hasMany(User::class,'company_id','id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user