Exemplo n.º 1
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot(Guard $auth)
 {
     view()->composer('*', function ($view) {
         $pages = Page::orderBy('position', 'asc')->get();
         $view->with('pages', $pages);
     });
     view()->composer('*', function ($view) {
         $view->with('currentUser', Auth::user());
     });
     view()->composer('sidebar.special', function ($view) {
         $specialProduct = Product::where('special', 1)->get();
         $view->with('specialProduct', $specialProduct);
     });
     view()->composer('sidebar.admin', function ($view) {
         $today = \Carbon\Carbon::today();
         $orders = DB::table('orders')->where('dateOrdered', '=', $today)->where('status_id', '>', 1)->count('id');
         $view->with('orders', $orders);
     });
     view()->composer('sidebar.admin', function ($view) {
         $today = date('l');
         $hours = DB::table('hours')->where('day', $today)->value('hours');
         $view->with('hours', $hours);
     });
     view()->composer('sidebar.admin', function ($view) {
         $batches = Batch::where('proddate', \Carbon\Carbon::today())->count();
         $view->with('batches', $batches);
     });
     view()->composer('sidebar.admin', function ($view) {
         $date = date('Y-m-d');
         $shift = Shift::where('date', $date)->pluck('id');
         $employeees = Shift::find($shift)->users()->count();
         $view->with('employeees', $employeees);
     });
     view()->composer('sidebar.special', function ($view) {
         $categories = Category::all();
         $view->with('categories', $categories);
     });
     view()->composer('*', function ($view) use($auth) {
         $user = Auth::user();
         if (Auth::user()) {
             $cart = DB::table('orders')->select('id')->where('status_id', '=', 1)->where('user_id', '=', $user->id)->value('id');
             $cartItems = DB::table('order_products')->where('order_id', '=', $cart)->sum('quantity');
             $view->with('cartItems', $cartItems);
         }
     });
 }
Exemplo n.º 2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $date = new \DateTime();
     $date->modify('+3 days');
     $formatted_date_from = $date->format('Y-m-d');
     $date->modify('+6 days');
     $formatted_date_to = $date->format('Y-m-d');
     $dates = createDateRangeArray(strtotime($formatted_date_from), strtotime($formatted_date_to));
     $bases = Base::where('center', 1)->get();
     $current_gen = Gen::getCurrentGen();
     $shiftSessions = ShiftSession::where('active', 1)->get();
     $lastShift = Shift::where('gen_id', $current_gen->id)->orderBy('week', 'desc')->first();
     $week = $lastShift ? $lastShift->week : 0;
     foreach ($dates as $date) {
         foreach ($bases as $base) {
             foreach ($shiftSessions as $shiftSession) {
                 $shift = new Shift();
                 $shift->gen_id = $current_gen->id;
                 $shift->base_id = $base->id;
                 $shift->shift_session_id = $shiftSession->id;
                 $shift->week = $week + 1;
                 $shift->date = $date;
                 $shift->save();
             }
         }
     }
     $role_ids = Tab::find(35)->roles->pluck('id')->unique()->toArray();
     $roles = Role::whereIn('id', $role_ids)->get();
     if ($week == 0) {
         $week = 1;
     }
     foreach ($roles as $role) {
         $users = $role->users;
         foreach ($users as $user) {
             send_mail_regis_shift($user, $week, $current_gen, ['*****@*****.**']);
         }
     }
     $this->info('done');
 }