laravel/framework — pull request #5347 by JosephSilber (2014-08-05 23:54:33+00:00)
Title: Resolve traits

As it stands, there's no way to inject stuff into a trait. To use other classes you have to either new them up or use a facade (if it has one).

This PR would allow for traits to declare their own pseudo constructors, which would then be resolved out of the IoC Container. For example, let's modify @JeffreyWay's [CommanderTrait](https://github.com/laracasts/Commander/blob/master/src/Laracasts/Commander/CommanderTrait.php):

```php
use Illuminate\Foundation\Application;

public function constructCommanderTrait(Application $app)
{
$this->app = $app;
}

public function getCommandBus()
{
return $this->app->make('Laracasts\Commander\CommandBus');
}
```

Here's we're injecting the whole container, but this is just an example. You might want to inject the logger or the mailer or just about anything else.

I think this would be very useful.