<?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();
		});
	}
}