Skip to content
Snippets Groups Projects
Commit f4e2923f authored by Afrizal Fikri's avatar Afrizal Fikri
Browse files

mail notif and update schedule table

parent 1dc5631e
Branches
No related merge requests found
Pipeline #1605 skipped
......@@ -46,7 +46,7 @@ class ScheduleController extends Controller
}
else
{
return view('menu.schedule',['data' => Schedule::where('id_user', Auth::user()->id)->get()]);
return view('menu.schedule', ['data' => Schedule::where('id_user', Auth::user()->id)->get()]);
}
}
......@@ -77,7 +77,15 @@ class ScheduleController extends Controller
{
$sched = Schedule::find($id);
$sched->update($input);
return $sched;
$tps = $sched->tps();
$tps->capacity_now += $sched->amount;
if ($tps->capacity_now >= $tps->capacity_full)
{
notify('TPS '.$tps->name.' penuh');
}
return redirect('/schedule');
}
public function destroy($id)
......@@ -85,4 +93,16 @@ class ScheduleController extends Controller
Schedule::find($id)->delete();
return Schedule::all();
}
public function notify($notif)
{
$data = [
'content' => $notif,
];
Mail::send('emails.welcome', $data, function ($message) {
$message->from(env('MAIL_USERNAME', 'user@host.suffix'), 'Notifikasi');
$message->to($request->input('email'))->subject('Notifikasi Status TPS');
});
}
}
\ No newline at end of file
......@@ -53,17 +53,17 @@ class TpsController extends Controller
$tmp->managerName = $tps->manager()->get(['name'])[0]->name;
array_push($arr,$tmp);
}
return view('menu.tps',['data' => $arr]);
return view('menu.tps', ['data' => $arr]);
}
public function store()
{
$tps = new Tps;
$tps->capacity_now = Input::get('capacity_now',0);
$tps->capacity_full = Input::get('capacity_full',0);
$tps->capacity_now = Input::get('capacity_now', 0);
$tps->capacity_full = Input::get('capacity_full', 0);
$tps->nama = Input::get('name','');
$tps->is_full = Input::get('is_full',0);
$tps->id_manager = Input::get('idPengelola',0);
$tps->is_full = Input::get('is_full', 0);
$tps->id_manager = Input::get('idPengelola', 0);
$tps->id = 0;
$tps->save();
//$tps = Tps::create(Input::all());
......@@ -73,7 +73,9 @@ class TpsController extends Controller
public function create()
{
// view create doang
return view('menu.insertTps',['dataManager' => User::all(['id','name'])]);
return view('menu.insertTps', [
'dataManager' => User::all(['id', 'name'])
]);
}
public function show($id)
......@@ -85,17 +87,21 @@ class TpsController extends Controller
public function edit($id)
{
// viewnya pake form edit
return view('menu.editTps',['id'=>$id,'data' => Tps::find($id),'dataManager' => User::all(['id','name'])]);
return view('menu.editTps', [
'id' => $id,
'data' => Tps::find($id),
'dataManager' => User::all(['id', 'name'])
]);
}
public function update($id)
{
$tps = Tps::find($id);
$tps->capacity_now = Input::get('capacity_now',0);
$tps->capacity_full = Input::get('capacity_full',0);
$tps->nama = Input::get('name','');
$tps->is_full = Input::get('is_full',0);
$tps->id_manager = Input::get('idPengelola',0);
$tps->capacity_now = Input::get('capacity_now', 0);
$tps->capacity_full = Input::get('capacity_full', 0);
$tps->nama = Input::get('name', '');
$tps->is_full = Input::get('is_full', 0);
$tps->id_manager = Input::get('idPengelola', 0);
$tps->save();
return redirect('/tps');
}
......
......@@ -43,7 +43,7 @@ class UserController extends Controller
public function index()
{
return view('menu.user',['data' => User::all()]);
return view('menu.user', ['data' => User::all()]);
}
public function store()
......@@ -70,7 +70,10 @@ class UserController extends Controller
public function edit($id)
{
// viewnya pake form edit
return view('menu.editUser',['id'=>$id,'data' => User::find($id)]);
return view('menu.editUser', [
'id' => $id,
'data' => User::find($id)
]);
}
public function update($id)
......
......@@ -13,6 +13,7 @@
Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::get('/', 'HomeController@index'); // homnya kan cm 1
Route::get('/home', 'HomeController@index');
......
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class UsersRoles extends Model
{
public function user()
{
return $this->hasOne('App\User', 'id', 'id_user');
}
public function role()
{
return $this->hasOne('App\User', 'id', 'id_role');
}
}
......@@ -17,6 +17,7 @@ class CreateSchedulesTable extends Migration
$table->increments('id');
$table->integer('id_tps')->unsigned();
$table->integer('id_user')->unsigned();
$table->integer('amount')->unsigned();
$table->boolean('is_done');
$table->timestamp('time');
$table->timestamps();
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="">
</head>
<body>
<div>
{{ content }}
</div>
</body>
</html>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment