Reputation: 140
i developing a laravel 5 package and now i want to use: interface Gate, on laravel.
in order to use interfaces, i should do by this way:
public function boot(GateContract $gate)
{
...code...
$gate->define($permission->name)
...Codes...
}
but i want to know is there another way use GateContract $gate without using argument of function or with using extend from class.
i mean, can i use like this way:
$gate = new Gate;
or any thing else,
Upvotes: 1
Views: 88
Reputation: 8673
Try something like that
$gate = $this->app->make('Gate');
There is more information about the Laravel Service container which instantiates objects over here https://laravel.com/docs/5.2/container
Upvotes: 1