emergingdzns - 6 months ago

I have a stream called "ManagerSettings" and in the src structure there's a file called ManagerSetting/Contract/ManagerSettingsRepositoryInterface.php. Below is the file content:

<?php
namespace My\ExampleModule\ManagerSetting\Contract;

use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface;

interface ManagerSettingRepositoryInterface extends EntryRepositoryInterface
{
    public function findByUserId($user_id);
}

In my controller I have a function like this:

    use My\ExampleModule\ManagerSetting\Contract\ManagerSettingRepositoryInterface;
    ...
    public function managerIndex(ManagerSettingRepositoryInterface $managers) {
        if (Auth::user()->hasRole('manager')) {
            ... some code here
        } else {
            ... redirect here
        }
    }

But after logging with a user that has the right role and permissions I now get these two error messages:

Target [My\ExampleModule\ManagerSetting\Contract\ManagerSettingRepositoryInterface] is not instantiable. {"userId":xxx,"email":"xxx@yyy.com","exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Target [My\\ExampleModule\\ManagerSetting\\Contract\\ManagerSettingRepositoryInterface] is not instantiable. at /home/forge/myapp.com/vendor/laravel/framework/src/Illuminate/Container/Container.php:918)
...
Call to a member function parameters() on null {"userId":xxx,"email":"xxx@yyy.com","exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to a member function parameters() on null at /home/forge/myapp.com/vendor/laravel/framework/src/Illuminate/Http/Request.php:561)

I've spent the last few hours trying to trace this out but I'm completely lost. I've run all the artisan commands assets:clear, view:clear, twig:clear, clear-compiled. Help would be appreciated.

Answer

william - 6 months ago

I am basically getting at that you might not have bound it yet?

william - 6 months ago

What does your provider look like?

william - 6 months ago

I am basically getting at that you might not have bound it yet?

emergingdzns - 6 months ago

ARGH. Thanks William! Usually adding the stream and migrating does it automatically.

william - 6 months ago

No worries:)