Reputation: 33
How to call dynamic Model in Laravel 4 ?
Imagine that I have this
$job = CfgJob::orderBy('Name')->get();
What I want to do is to pass value to call the model. Something like this
$value='Job';
$job = Cfg.$value::orderBy('Name')->get();
Is it possible to this on PHP and Laravel 4 ?
Upvotes: 0
Views: 1096
Reputation: 60038
I think this might work (cant test it at the moment):
$value='Job';
$value= ('Cfg'.$value);
$job = $value::orderBy('Name')->get();
Upvotes: 1