How to define Global Variables in Laravel?

Report
Question
777 views

First we have to create global.php file in config folder of your laravel application. I did add three variable in that file : siteTitle, pagination and tagLine. We can get global variable value on controller, view, model and anywhere.

Please explain why do you think this question should be reported?

Report Cancel

//config/global.php

return [

'siteTitle' => 'HD Site',

'pagination' => 5,

'tagLine' => 'Do the best'

];

 

//any controller,view,model

{{ config('global.siteTitle') }}

Thread Reply

Leave an comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>