Ok, so changing the service provider like so:
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Support\UserMessage\UserMessage;
use App\Contracts\UserMessageContract;
class UserMessageProvider extends ServiceProvider
{
protected $defer = true;
public function register()
{
$this->app->singleton(UserMessageContract::class, function ($app)
{
return new UserMessage();
});
$this->app->alias(UserMessageContract::class, 'usermessage');
}
public function provides()
{
return [UserMessageContract::class, 'usermessage'];
}
}
gives the desired result. The class gets resolved out of the IoC container and I can still use the alias, i.e app('usermessage');
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community