Search
 
SCRIPT & CODE EXAMPLE
 

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')
Comment

PREVIOUS NEXT
Code Example
Php :: PHP - AJAX and MySQL 
Php :: what is php artisan 
Php :: laravel find model inside the same model 
Php :: Laravel save without an event 
Php :: register_uninstall_hook 
Php :: distinct in laravel 8 
Php :: heroku deploy php 
Php :: symfony get locale from request in controller 
Php :: php declare variable 
Php :: woocommerce_product_is_on_sale filter 
Php :: phpdoc @var 
Php :: map array php 
Php :: pre_get_posts order by title 
Php :: $faker-paragraph 
Php :: sometimes validation in laravel 
Php :: php remove everything before colon 
Php :: Sending HTML Code Through JSON 
Php :: laravel where condition with if 
Php :: drupal 8 $_GET 
Php :: Call to undefined method CI_DB_mysqli_result::order_by() 
Php :: PHP Iterables 
Php :: using custom fonts in php 
Php :: Laravel Extract Values From Collection Using Pluck() with Relationship 
Php :: checkout 
Php :: phpunit test only one method 
Php :: pass data to blade laravel 
Php :: laravel check if query builder is empty 
Php :: get image field in custom post type category taxonomy 
Php :: laravel link to css or image 
Php :: how to make primary key and foreign key in phpmyadmin 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =