Forum

Laravel 8 - string ...
 
Notifications
Clear all

Laravel 8 - string to model name

1 Posty
1 Users
0 Reactions
478 Widok
0
Topic starter

how to

1 Answer
0
Topic starter
$targetModelName = "myModelName";

$model = app("App\Models\\$targetModelName")->find($targetId);
dd($model);

Odpowiedź

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved
Share: