-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
  • 10,491
  • 5
  • 12
  • 29
Chiko
  • 2,298
  • 4
  • 18
  • 27

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
  • 205,539
  • 55
  • 352
  • 286