mercredi 24 février 2016

Laravel 5.1 - Retrieving single Models using string instead of the name of the model

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?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire