jeudi 29 octobre 2015

Make a variable accessable from anywhere within the Laravel application

I make a cURL request to an API

http://site/user


I got back this response

    data: Object
    first_name: "Bob"
    last_name: "Jones"


I grab the first name and last name and concatenate them together and stored into a variable call $name.

$fn = VSE::user('first_name',$username);
$ln = VSE::user('last_name',$username);
$name = ucwords($fn.' '.$ln); // Bob Jones

I want to display this $name on my navigation.

Sending this $name variable with every view would be a little over kill. I'm seeking for a better way of doing this.

What should I do to make that variable accessable throughout my application routes/views ?


Restriction: I don't have the access to the Auth::user object.



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

Aucun commentaire:

Enregistrer un commentaire