mercredi 22 février 2017

How to make a variable accessable to the whole controller in laravel

Lets say I have a

IndexController

Which contains a function

public function store($store)
{
    $store = (query)->get();
    return $store;
}

Now I want one column from store to be accessible to all functions like

$id = $store->id

I want it to be usable like this

public function abv()
{
    $categories = (query)->where('id','=',$id)->get();
}

My point is that it becomes a global variable to the whole controller. How do I achieve this?



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

Aucun commentaire:

Enregistrer un commentaire