Hi I am studying laravel. I use Eloquent ORM delete method but I get a different result.Not true or false but null. I set an resource route and there is a destroy method in UsersController.
public function destroy($id){
$res=User::find($id)->delete();
if ($res){
$data=[
'status'=>'1',
'msg'=>'success'
];
}else{
$data=[
'status'=>'0',
'msg'=>'fail'
];
return response()->json($data);
但我总是得到一个响应{"status":"0","msg":"failed"},数据库中的记录被删除.
Then I use dd($res) .It shows null in the page.
但我从课程中了解到,它返回布尔值true或false.
我的代码有错误吗?
Can you tell me some other method that I can get a boolean result when I delete data from database?