CourseWork/app/Providers/ModelServiceProvider.php
2024-04-23 14:52:49 +04:00

56 lines
1.4 KiB
PHP

<?php
namespace App\Providers;
use App\Http\Controllers\GradeController;
use App\Http\Controllers\StudentController;
use App\Http\Controllers\SubjectController;
use App\Http\Controllers\TeacherController;
use App\Services\GradeService;
use App\Services\ServiceInterface;
use App\Services\StudentService;
use App\Services\SubjectService;
use App\Services\TeacherService;
use Illuminate\Support\ServiceProvider;
class ModelServiceProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
$this->app->when(StudentController::class)
->needs(ServiceInterface::class)
->give(function () {
return new StudentService();
});
$this->app->when(TeacherController::class)
->needs(ServiceInterface::class)
->give(function () {
return new TeacherService();
});
$this->app->when(GradeController::class)
->needs(ServiceInterface::class)
->give(function () {
return new GradeService();
});
$this->app->when(SubjectController::class)
->needs(ServiceInterface::class)
->give(function () {
return new SubjectService();
});
}
/**
* Bootstrap services.
*/
public function boot(): void
{
//
}
}