Support the ongoing development of Laravel.io →
Eloquent
Last updated 1 month ago.
0

You could try this,


$model = fetchContents('App\Database\Models\Documents');

function fetchContents($model)
{
    return \App::make($model)->all();

    // or 
    // if all models are in the same namespace, you could then just use just a model name in the function call
    // and "hardcode" the namespace...
    return \App::make('App\Database\Models\'.$model)->all();

    // depending on where the fetchContents function is you might also be able to use 
    // $this->app->make('...

}

0

Sign in to participate in this thread!

LoadForge

Your banner here too?

VenomRush VenomRush venomrush Joined 27 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.