I´m working with polymorphic in Laravel 5.2. I want to set for the name of model string. There si code:
switch ($passport->element_type) {
case 'Window':
$windows = Window::find($passport->element_id);
break;
case 'Floor':
$floor = Floor::find($passport->element_id);
break;
case 'Wall':
$wall = Wall::find($passport->element_id);
default:
break;
}
};
You can see that variable "$passport->element_type" gives me the name of my model. I don´t want to do it with switch-case. Is it possible to do something like:
$passport->element_type::find($passport->element_id);
or how can I use the variable (element_type) as the name for model?