Answer the question
In order to leave comments, you need to log in
Why doesn't binding an interface to a class work in a ServiceProvider?
I use this binding
$this->app->bind(BoardRepository::class, EloquentBoardRepository::class);
But passing the BoardRepository $boardRepository parameter in the controller does not cause any errors. I remove the parameter and everything is ok. Tell me, please, what could be wrong. I fight already the second day.
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Repositories\Contracts\BoardRepository;
use App\Repositories\EloquentBoardRepository;
class RepositoriesServiceProvider extends ServiceProvider
{
protected $defer = true;
public function register()
{
$this->app->bind(BoardRepository::class, EloquentBoardRepository::class);
// $this->app->bind(NoteRepository::class, EloquentNoteRepository::class);
}
public function provides()
{
return [
BoardRepository::class,
// NoteRepository::class,
];
}
}
public function __construct(BoardRepository $boardRepository)
{
dd($boardRepository);
//$this->boardsRepository = $boardsRepository;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question