dimanche 20 mai 2018

Display a SQL request on a partial page not a view Laravel 5.5

I have a laravel layout which have "partials pages". I call them in the layout by using includes :

@include('admin.partials.nav')

My issue is that I have to put in the nav page an SQL result on each page that use this navigation.

For this i created a method in a specific class named UtilsClass :

class UtilsController extends Controller {

public function vcList(){
    $valuechainLists = Valuechain::select('valuechains.id', 'lang_valuechain.vcname', 'lang_valuechain.vcshortname')
        ->join('lang_valuechain', 'valuechains.id', '=', 'lang_valuechain.valuechain_id')
        ->join('langs', 'lang_valuechain.lang_id', '=', 'langs.id')
        ->where('langs.isMainlanguage', '=', '1')
        ->whereNull('valuechains.deleted_at')
        ->get();

    return $valuechainLists->toArray();
}

}

Now my issue is the following :

  • How to get the return of this request on each method that is returning a view that uses the layout which uses this navigation ?
  • How do i pass the array from this method to other methods in other classes ? Do i have to add something like this : use App\Http\Controllers\BackOffice\UtilsController in the class that would use the concerned layout ?

Thanks



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2rXe5SL
via IFTTT

Aucun commentaire:

Enregistrer un commentaire