From 3c4f84168222aec85b352734ce27a764278f4d36 Mon Sep 17 00:00:00 2001 From: gazandic <gazandic@gmail.com> Date: Wed, 6 Apr 2016 13:17:17 +0700 Subject: [PATCH] nambah notif supir --- app/Http/Controllers/ScheduleController.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ScheduleController.php b/app/Http/Controllers/ScheduleController.php index 144b3c4..2c284c2 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 -- GitLab