I am using one function in controller for inserting in several different tables with different Models. I mean that in controller model is variable.
This code bellow works perfectly but i don't like syntax, i am pretty sure there must be some other ways than str_replace for calling model with \App\ in front of it's name.
Calling only by Model name without \App\ causes laravel error Class not found. I have written use \App\ModelName in controller's file but it still does't works.
public function storeCommon(Request $request){
$model = '"\App\"'. $request->model;
$model = str_replace ( "\"", "", $model ) ;
........
........
$row['text'] = $request->text;
........
........
$common = $model::create($row);
}