我有一张发票表,它的 struct 如下
id | name | amount | deleted_at
2 iMac 1500 | NULL
and a payments table with the following structure
id | invoice_id | amount | deleted_at
2 2 1000 | NULL
Invoice Model
class Invoice extends Model {
use SoftDeletes;
}
以下是删除发票的代码
public function cance(Request $request,$id)
{
$record = Invoice::findOrFail($id);
$record->delete();
return response()->json([
'success' => 'OK',
]);
}
Payments model
class Payment extends Model {
use SoftDeletes;
}
发票表上的softDelete工作正常,但其相关记录(付款)仍然存在.如何使用softDelete删除它们?