Search code examples
phpmysqllaraveldelete-row

how to delete multiple ids in laravel?


my table name is paids and i want to delete all the ids which have same ot_id here is my databsae

i have data like this

 |id|  |ot_id|
   1      20
   2      20
   3      20
   4      20
   5      20
   6      20
public function deleteOT($id)
{
    $deleteid = Paid::where();
    return Common::Message("Order Taker", 3);
}

here i want to delete how i can do that in laravel?


Solution

  • You should spend some time reading Laravel docs, which are very good source for learning the basics.

    public function deleteOt($id)
    {
        Paid::where('ot_id', $id)->delete();
    
        return Common::Message("Order Taker", 3);
    }