Support the ongoing development of Laravel.io →
posted 8 years ago
Eloquent
Last updated 1 year 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!

Eventy

Your banner here too?

VenomRush venomrush Joined 27 May 2014

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.