mardi 22 mai 2018

Creating a Model From a URL parameter in laravel

I am trying to create an instance of a class based on a parter that is passed in by the url. This is what I have so far. I found a question about this that was asked more than two. years ago using this same format, but I am getting an error.

public function completed($type,$id){
     $model = app("\App\{$type}");
}

The error I get is :

Class \App{EmailMessage} does not exist

It seems like the string interpolation is not working correctly.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2khyD5h
via IFTTT

Aucun commentaire:

Enregistrer un commentaire