init commit
This commit is contained in:
63
app/Providers/RepositoryServiceProvider.php
Normal file
63
app/Providers/RepositoryServiceProvider.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?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
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user