7 months ago

Import model without namespacing it

Posted 7 months ago by m33bo

I am trying to import a model via an Ajax request without namespacing the model.

public function dataTypeRender(Request $request)
    $input = request()->all();
    $model = $request->input('model'); //this is the model name
    $cols = $request->input('cols');

    $modelTest = $model::all(); //not working

However it returns model not found. Is there a way to do this? The model is going to be dynamic so namespace doesnt really help

Please sign in or create an account to participate in this conversation.