Msoft
11 months ago
136
11
Laravel

Why did not delete table records in Laravel 5?

Posted 11 months ago by Msoft

working with Laravel and has table called as vehicles and I need delete table records who are logged with the app and related to create records with logged user, I am showing logged user records with following

vehicle model

public function scopePersonal($query)
{
     return $query->where('user_id', Auth::user()->id);

}

and VehcicleController

public function indexpersonel()
    {
         $vehicles = Vehicle::personal()->get();
        return view('vehicles.myads')->withVehicles($vehicles);
    }

and my ads delete buttons link

<td><a class="button is-outlined" href="/myads/{{$vehicule->id}}/delete" onclick="return confirm('Are you sure to want to delete this record?')" >Delete</a></td>

and vehicle controller delete function

public function deleteOneAd($id)
    {
        DB::table('vehicles')
            ->where('id', $id)

            ->delete();
        return redirect()->back();
}

but when I clicked delete button and accept javascripts popup it is not deleting vehicles table records. how can I fix this problem?

Please sign in or create an account to participate in this conversation.