vendredi 6 novembre 2015

Laravel delete query returns 0 affected rows

I am wanting to check if rows were affected after a delete statement in Laravel.

My code:

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;
}

The die & dump constantly returns 0 even though a record is being removed.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire