-3

I would like to know the best way to go about displaying a value from the database system wide in Laravel 5?

Basically, all authenticated users should have it set and I want to use it in a couple of places.

Thanks.

OMR
  • 11,736
  • 5
  • 20
  • 35
Chiko
  • 2,330
  • 4
  • 21
  • 29

1 Answers1

0

Without knowing too much about your setup/needs, I'd say you should create your own helpers file and put a simple function in there:

function special_value()
{
    static $value;

    if (is_null($value)) {
        $value = DB::table('the_table')->value('the_column');
    }

    return $value;
}

Then, wherever you need the value, just call special_value() to get it.

Community
  • 1
  • 1
Joseph Silber
  • 214,931
  • 59
  • 362
  • 292