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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s