コード例 #1
0
ファイル: Admin.php プロジェクト: rosemalejohn/dnsc-hris
 /**
  * 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'));
     }
 }
コード例 #2
0
 /**
  * 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!');
 }
コード例 #3
0
 /**
  * @param Request $request
  */
 public function store(Request $request)
 {
     if ($this->validator($request->all())->fails()) {
         flash()->error('You have missing fields.');
         return redirect()->back();
     }
     $training = Training::create($request->all());
     if ($training) {
         if (is_array($request->participants)) {
             foreach ($request->input('participants') as $participant) {
                 try {
                     if ($participant == 'all') {
                         foreach (Employee::all() as $employee) {
                             TrainingParticipant::create(['training_id' => $training->id, 'employee_id' => $employee->id]);
                             // $training->employees()->attach($employee->id);
                         }
                         break;
                     } elseif (is_object(json_decode($participant))) {
                         $participant = json_decode($participant);
                         foreach (Department::find($participant->id)->users as $user) {
                             TrainingParticipant::create(['training_id' => $training->id, 'employee_id' => $user->employee->id]);
                             // $training->employees()->attach($user->employee->id);
                         }
                     } else {
                         TrainingParticipant::create(['training_id' => $training->id, 'employee_id' => $participant]);
                         // $training->employees()->attach($participant);
                     }
                 } catch (QueryException $ex) {
                 }
             }
         }
         flash()->success('Successfully added the trainings and seminar.');
     } else {
         flash()->error('Oopss! Something went wrong.');
     }
     return redirect()->back();
 }
コード例 #4
0
 public function destroy($id)
 {
     $training = Training::findOrFail($id)->delete();
     return response()->json('Deleted!', 200);
 }