我有这样一个发票表,其结构如下:
id | name | amount | deleted_at
2 iMac 1500 | NULL
并带有以下结构的付款表格
id | invoice_id | amount | deleted_at
2 2 1000 | NULL
发票模板
class Invoice extends Model {
use SoftDeletes;
}
这里是删除发票的代码
public function cance(Request $request,$id)
{
$record = Invoice::findOrFail($id);
$record->delete();
return response()->json([
'success' => 'OK',
]);
}
支付模型
class Payment extends Model {
use SoftDeletes;
}
Invoice表的软删除功能运作正常,但其相关记录(付款)仍然存在。如何使用软删除删除它们?