Esempio n. 1
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     if (auth()->user()->employee) {
         $stats = collect();
         $sessions = $this->session->getActiveUsers();
         $stats->push(['title' => 'System users', 'class' => 'info', 'icon' => 'users', 'number' => User::count(), 'description' => 'Registered user account in the system', 'url' => '/employee']);
         $stats->push(['title' => 'User with PDS', 'class' => 'success', 'icon' => 'user', 'number' => round(Employee::count() / User::count() * 100, 0) . '%', 'description' => Employee::count() . ' employees with Personal Data Sheet', 'url' => '/employee']);
         $stats->push(['title' => 'Leave Request', 'class' => 'danger', 'icon' => 'thumbs-o-up', 'number' => EmployeeLeave::approved()->count(), 'description' => '<i class="fa fa-thumbs-o-up"></i>&nbsp;' . EmployeeLeave::count() . ' Total filed leaves', 'url' => 'leave']);
         $stats->push(['title' => 'Upcoming Trainings', 'class' => 'warning', 'icon' => 'calendar', 'number' => Training::where('start', '>', Carbon::today())->count(), 'description' => '<i class="fa fa-calendar"></i>&nbsp; ' . Training::count() . ' Trainings & Seminar', 'url' => '/calendar']);
         $view->with(compact('stats', 'sessions'));
     }
 }
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     foreach (Training::where('start', Carbon::today())->get() as $training) {
         $training->employees->each(function ($employee) use($training) {
             $training->notifications()->create(['sent_to' => $employee->user->id, 'sent_by' => getAdmin()->id, 'subject' => 'Trainings and Seminar', 'message' => $training->title . ' is scheduled to start today!', 'icon' => 'calendar', 'color' => 'primary']);
         });
     }
     foreach (Training::where('end', Carbon::today())->get() as $training) {
         $training->employees->each(function ($employee) use($training) {
             $training->notifications()->create(['sent_to' => $employee->user->id, 'sent_by' => getAdmin()->id, 'subject' => 'Trainings and Seminar', 'message' => $training->title . ' is scheduled to end today! Share us your thoughts.', 'icon' => 'calendar', 'color' => 'primary']);
         });
     }
     $this->info('Participants are all notified!');
 }