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//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?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire