Laravel删除查询返回0个受影响的行

时间:2015-11-06 16:16:17

标签: php laravel laravel-5.1

我想在Laravel中的删除语句后检查行是否受到影响。

我的代码:

private function removeUserOutstandingRecord()
{
    $query = UserOutstanding::where('o_id', $this->outstanding_id)->delete();

    dd($query);

    if(!$query) {
        Log::error('Could not delete user outstanding record. Outstanding ID given: ' . $this->outstanding_id);
        throw new \Exception('Oops.');
    }

    return true;
}

模具&即使已删除记录,dump也会返回0

0 个答案:

没有答案