This repository has been archived on 2026-09-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
tutoring/app/Providers/RouteBindingServiceProvider.php
2026-01-14 00:54:08 +00:00

33 lines
791 B
PHP

<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Route;
use App\Models\Course;
use App\Models\Chapter;
use App\Models\Lesson;
use App\Models\LessonSection;
class RouteBindingServiceProvider extends ServiceProvider
{
public function boot(): void
{
Route::bind('course', function ($value) {
return \App\Models\Course::where('slug', $value)->firstOrFail();
});
Route::bind('lesson', function ($value) {
return \App\Models\Lesson::where('slug', $value)->firstOrFail();
});
Route::bind('chapter', function ($value) {
return \App\Models\Chapter::where('slug', $value)->firstOrFail();
});
Route::bind('section', function ($value) {
return LessonSection::where('slug', $value)->firstOrFail();
});
}
}