对应关系已经处理好
public function link()
{
return $this->belongsTo(Link::class);
}
public function linkItem()
{
return $this->hasMany(LinkItem::class);
}
//批量删除
public function deleteMoreLink($ids){
if ($ids){
$link=Link::whereIn('id',$ids)->linkItem()->delete();
//如果删除成功
if ($link){
$data=[
'status'=>1,
'msg'=>'删除成功!'
];
}else{
$data=[
'status'=>0,
'msg'=>'删除失败!'
];
}
return response()->json($data);
}
abort('404');
}
但是出现500错误!
Call to undefined method IlluminateDatabaseQueryBuilder::linkItem()