64 lines
1.4 KiB
PHP
64 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
// Interfaces
|
|
use App\Interfaces\UserRepositoryInterface;
|
|
use App\Interfaces\ResumeRepositoryInterface;
|
|
|
|
// Repositories
|
|
use App\Repositories\UserRepository;
|
|
use App\Repositories\ResumeRepository;
|
|
|
|
// Models
|
|
use App\Models\User;
|
|
use App\Models\Resume;
|
|
|
|
/**
|
|
* Repository Service Provider
|
|
*
|
|
* Binds repository interfaces to their concrete implementations.
|
|
* Enables dependency injection throughout the application.
|
|
*
|
|
* @author David Valera Melendez <david@valera-melendez.de>
|
|
* @since February 2025
|
|
*/
|
|
class RepositoryServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* All of the container bindings that should be registered.
|
|
*
|
|
* @var array
|
|
*/
|
|
public array $bindings = [
|
|
UserRepositoryInterface::class => UserRepository::class,
|
|
ResumeRepositoryInterface::class => ResumeRepository::class,
|
|
];
|
|
|
|
/**
|
|
* Register services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
// Bind User Repository
|
|
$this->app->bind(UserRepositoryInterface::class, function ($app) {
|
|
return new UserRepository(new User());
|
|
});
|
|
|
|
// Bind Resume Repository
|
|
$this->app->bind(ResumeRepositoryInterface::class, function ($app) {
|
|
return new ResumeRepository(new Resume());
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Bootstrap services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
//
|
|
}
|
|
}
|