app/Providers/AppServiceProvider.php
/**
     * Bootstrap any application services.
     *
     * @return void
     */
Bootstrap any application services.
@return void
Bootstrap any application services . @return void
public function boot()
    {
        view()->composer('*',function($view){
            $user = User::where('id',Auth::id())->first();
            $donvi = DB::table('db_donvi')->get();
            $loai_sp = DB::table('db_loaisp_nckh')->get();
            $donvi_khac_1 = DB::table('users')->join('model_has_roles','users.id','=','model_has_roles.model_id')->select('donvi_khac')->where('role_id','4')->distinct()->get();
            $user_tt_1 = DB::table('users')->join('model_has_roles','users.id','=','model_has_roles.model_id')->where('role_id','4')->distinct()->get();
            $view->with(compact('user','donvi','loai_sp','donvi_khac_1','user_tt_1'));
        });
    }
public function boot ( ) { view ( ) -> composer ( '*' , function ( $ view ) { $ user = User :: where ( 'id' , Auth :: id ( ) ) -> first ( ) ; $ donvi = DB :: table ( 'db_donvi' ) -> get ( ) ; $ loai_sp = DB :: table ( 'db_loaisp_nckh' ) -> get ( ) ; $ donvi_khac_1 = DB :: table ( 'users' ) -> join ( 'model_has_roles' , 'users.id' , '=' , 'model_has_roles.model_id' ) -> select ( 'donvi_khac' ) -> where ( 'role_id' , '4' ) -> distinct ( ) -> get ( ) ; $ user_tt_1 = DB :: table ( 'users' ) -> join ( 'model_has_roles' , 'users.id' , '=' , 'model_has_roles.model_id' ) -> where ( 'role_id' , '4' ) -> distinct ( ) -> get ( ) ; $ view -> with ( compact ( 'user' , 'donvi' , 'loai_sp' , 'donvi_khac_1' , 'user_tt_1' ) ) ; } ) ; }
Bootstrap any application services.
Bootstrap any application services .