laravel global variable

Posted by w3diy - 6 months ago

Define Global Variable in Laravel

Create Global Config File

config/global.php

<?php

return [

    'pagination_records' => 25,

    'user_type' => ['User', 'Admin'],
]

?>  

Use Global Variable

routes/web.php

Route::get('get-user-type', function()
{
    dd(config('global.user_type'));
});

Route::get('get-user-type', function()
{
    dd(config('global.pagination_records'));
});