Reputation: 73
Sorry for title. I don't know what to write. This is my problem: If i write this is all ok:
$obj_license = License::where('licenses.company_id',$company->id)->first();
But this throw an error:
$license='License';
$obj_license = $license::where('licenses.company_id',$company->id)->first();
ERROR: Class 'Butchery_license' not found
This is just an example. I really need to have the second way working. There is a solution?
Upvotes: 1
Views: 23
Reputation: 163748
Try to use full path to a class:
$license='App\License';
$obj_license = $license::where('licenses.company_id',$company->id)->first();
Upvotes: 1