2

I'm using Laravel's Facade architecture (the AliasLoader class and Facade class) to create facades for my app. All is working well initially, I add the aliases to the loader and register them, create a facade class and boom, facades everywhere.

But now I'm trying to clean up my model calls.

Currently I'm loading the model Theme::model('sale/order') like so, this creates a model_sale_order object on the container. I'd like to also add a facade on the fly so that I can call the model more elegantly SaleOrder::getOrders($customer_id)

Adding the alias is no big deal, but where to point it? There is no facade file to point this too.

Is it possible to set up a class that could dynamically detect which object we're looking for from the container?

class DynamicFacade extends Facade {

    protected static function getFacadeAccessor() {
        return 'my.dynamically.created.object';
    }
}
secondman
  • 3,233
  • 6
  • 43
  • 66

0 Answers0