class - How to get Model Object using its name from a variable in Laravel 5? -


i trying information model using name sent parameter blade using ajax call.

$.get("{{ url('auditinformation')}}", {modelname: modelname,versions:versions,currentdata:currentdata[index]}); 

now need retrieve information using modelname model.

so when tried this:

$auditinfo=input::all();     $modelname=$auditinfo['modelname'];     $values=$modelname::find(1); 

i got response class 'designation' not found

but if use

$modelname=new designation();     $values=$modelname::find(1); 

then shows data want.

so understand model ( class ) object.

is there way assign object $modelname using $auditinfo['modelname'] .

thanks

if want way, should use model's namespace.

for example, if 'destination' model's namespace app\destination, should use :

$auditinfo=input::all(); $appprefix = 'app'; $modelname=$appprefix . '\' . $auditinfo['modelname']; $values=$modelname::find(1); 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -