Changed some:
edit.blade.php
@foreach($students"> <tr>
<td>{{ $student->name }}</td>
<td>{!! Form::open([
'method' => 'DELETE',
'route' => ['destroy', $student->id, $lesson->id]
]) !!}
{!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
<!-- <i class="glyphicon glyphicon-trash fa-1x" data-toggle="tooltip" title="Delete" style="color:#b94a48;"></i> -->
</td>
</tr>
@endforeach
routes.php
Route::delete('/admin/lessonstudents/{$user_id}/{$lesson_id}', [
'as' => 'destroy',
'uses' => 'Admin\LessonStudentsController@destroy'
]);
LessonStudentsController
public function destroy($user_id, $lesson_id)
{
// $lessonstudents = LessonStudent::find($id);
// $LessonStudents->delete();
$user = User::findOrFail($user_id);
dd($user);
$user->lessons()->detach($lesson_id);
// $lesson = Lesson::findOrFail($id);
// $students = $lesson->students;
return redirect('admin/lesson')->with('status', 'Succesfully delete user from lesson!');
So i fixed the second parameter issue because i was using it as a resource by accident. But now i'm getting this error:
NotFoundHttpException in RouteCollection.php line 161:
Not sure why?
I've done php artisan route:list and posted the relevant route result below:
| | GET|HEAD | admin/lessonstudents/{$user_id}/{$lesson_id} | destroy | App\Http\Controllers\Admin\LessonStudentsController@destroy | >web |