This has got to be an easy fix but I can't see the tree for the forest. :)
I added a delete button to a list of contacts so each contact could be deleted. I Href'ed it to the contacts.destroy route, with an alert confirmation. When I click the button the confirmation window comes up. I click OK, and it shows me the contact view and does not delete the record. I am using resource routes for "contacts":
Controller @destroy:
public function destroy($id)
{
$contact = Contact::find($id);
// Check for correct user
if(auth()->user()->id !== $contact->user_id){
return redirect('/contacts')->with('error', 'That Is Not Your Contact');
}
$contact->delete();
return redirect('/contacts')->with('success', 'Contact Removed');
}
Contacts View code for button:
<a class="btn btn-danger" onclick="return confirm('Are you sure you want to delete {{$contact->contact1firstname}} {{$contact->contact1lastname}}?')" href="{{route('contacts.destroy', $contact->id)}}">Delete</a>
Route as listed in the terminal:
| | POST | contacts | contacts.store | App\Http\Controllers\ContactsController@store
| web,auth |
| | GET|HEAD | contacts | contacts.index | App\Http\Controllers\ContactsController@index
| web,auth |
| | GET|HEAD | contacts/create | contacts.create | App\Http\Controllers\ContactsController@create
| web,auth |
| | DELETE | contacts/{contact} | contacts.destroy | App\Http\Controllers\ContactsController@destroy
| web,auth |
| | PUT|PATCH | contacts/{contact} | contacts.update | App\Http\Controllers\ContactsController@update
| web,auth |
| | GET|HEAD | contacts/{contact} | contacts.show | App\Http\Controllers\ContactsController@show
Why would it return my contacts.show view, showing the individual contact view?