CourseWork/app/Providers/ModelServiceProvider.php
2024-05-07 12:14:18 +04:00

72 lines
2.0 KiB
PHP

<?php
namespace App\Providers;
use App\Http\Controllers\GradeController;
use App\Http\Controllers\GradeSubjectController;
use App\Http\Controllers\StudentController;
use App\Http\Controllers\SubjectController;
use App\Http\Controllers\SubjectTeacherController;
use App\Http\Controllers\TeacherController;
use App\Services\GradeService;
use App\Services\GradeSubjectService;
use App\Services\ServiceInterface;
use App\Services\StudentService;
use App\Services\SubjectService;
use App\Services\SubjectTeacherService;
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();
});
$this->app->when(SubjectTeacherController::class)
->needs(ServiceInterface::class)
->give(function () {
return new SubjectTeacherService();
});
$this->app->when(GradeSubjectController::class)
->needs(ServiceInterface::class)
->give(function () {
return new GradeSubjectService();
});
}
/**
* Bootstrap services.
*/
public function boot(): void
{
//
}
}