Laravel Eloquent Find Not Working When Given String Model

Viewed 1637

I have A Model In Laravel stored in variable as String.

$model = "App\Models\City";

What I want is

$model::find(1) to fetch the City with ID of 1

But It's not working as it is expected. However, when I do

City::find(1)

Not using the $model variable. I can fetch my expected result.

Anyone?

3 Answers
Related