Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

access model in config laravel

//global variable
//Laravel - App/Providers/AppServiceProvider

use IlluminateSupportFacadesSchema;
use IlluminateSupportFacadesConfig;
use AppModelsUsersModel;

//in boot function
if (Schema::hasTable('users')) {
  $user = UsersModel::findOrFail(1);
  Config::set('user_type', $user->type);
}

//to access it use
config('user_type');
//or
Config::get('user_type')
 
PREVIOUS NEXT
Tagged: #access #model #config #laravel
ADD COMMENT
Topic
Name
6+4 =