How To Use Delete Statement In Laravel?

Loren
Written by Loren

Posted On: Jan 11, 2019

 

    1 Answer Written

  •  Loren
    Posted by Deshai

    Use delete statement in Laravel:

    In Query Builder Way:

    \DB::table('users')->delete($id); // delete with id
    \DB::table('users')->where('name', $name)->delete(); \\ delete with where condition
    

    In Eloquent Way:

     User::find($id)->delete() // delete with id
     User::where(['name'=>$name])->delete();  \\ delete with where condition
    
    

Please Login or Register to leave a response.

Related Questions