davy_yg's avatar

Call to undefined method App\Http\Controllers\ProfileController::delete()

I get this error message: Call to undefined method App\Http\Controllers\ProfileController::delete()

web.php

	Route::delete('profile/{id}', [ProfileController::class, 'delete'])->name('profile.delete');

admin/index.blade.php

	<table>
		<tr>
			<th>Foto</th>
			<th>NIM</th>
			<th>Nama</th>
			<th>Alamat</th>
			<th>Modify</th>
		</tr>
		@foreach($list as $item)
		<tr>
			<td><img src="{{ url(Storage::url($item->foto)) }}" height="25%" height="25%"></td>
			<td>{{ $item->nim }}</td>
			<td>{{ $item->nama }}</td>
			<td>{{ $item->alamat }}</td>
			<td>
			<form action="{{ route('profile.edit', $item->id) }}" method="GET">
				@csrf
				<button type="submit" class="btn btn-primary">Edit</button>
			</form>
			<form action="{{ route('profile.delete', $item->id) }}" method="POST">
				@csrf
				@method('DELETE')
			<button type="submit" class="btn btn-primary">Delete</button></td>
			</form>
			</tr>
		@endforeach
		</table>

The error appears after I pressed delete button.

0 likes
2 replies
Glukinho's avatar
Level 30

Do you have public function delete() method in ProfileController class?

davy_yg's avatar

Thanks I found the problem my function name destroy instead of delete!

1 like

Please or to participate in this conversation.