diff --git a/app/Http/Controllers/ScheduleController.php b/app/Http/Controllers/ScheduleController.php index 144b3c4c61a69b3505951a4fb754571aa1338cac..2c284c27f05b5f4fe254e7de0ed146598c4995b5 100644 --- a/app/Http/Controllers/ScheduleController.php +++ b/app/Http/Controllers/ScheduleController.php @@ -85,6 +85,8 @@ class ScheduleController extends Controller $sched->is_done = Input::get('is_done', 0); $sched->id = 0; $sched->save(); + $tps = Tps::find($sched->id_tps); + $this->notifySupir('jadwal anda ditambahkan pada TPS'.$tps->name.' pada tanggal '.$sched->time); } return redirect('/schedule'); } @@ -140,6 +142,8 @@ class ScheduleController extends Controller $sched->amount = Input::get('amount'); $sched->is_done = Input::get('is_done'); $sched->save(); + $tps = Tps::find($sched->id_tps); + $this->notifySupir('TPS '.$tps->nama.' penuh, jadwal anda di TPS tersebut berubah'); return redirect('/schedule'); } else if ($this->has_role('edit_schedule')) @@ -151,7 +155,7 @@ class ScheduleController extends Controller $tps->capacity_now += $sched->amount; if ($tps->capacity_now >= $tps->capacity_full) { - $this->notify('TPS '.$tps->nama.' penuh'); + $this->notify('TPS '.$tps->nama.' penuh. mohon dilakukan reschedule'); $tps->capacity_now = $tps->capacity_full; $tps->is_full = 1; } @@ -184,4 +188,15 @@ class ScheduleController extends Controller $message->to($user->email)->subject('Notifikasi Status TPS'); }); } + public function notifySupir($notif) + { + $data = [ + 'content' => $notif, + ]; + $user = Input::get('id_user'); + Mail::send('email.notification', $data, function ($message) use ($user) { + $message->from(env('MAIL_USERNAME', 'user@host.suffix'), 'Notifikasi'); + $message->to($user->email)->subject('Notifikasi Jadwal'); + }); + } } \ No newline at end of file