public function DelTeam($id, $id_team) { // Start Check Authorization /** * 1. FullAccess - 1 * 2. HRD - 3 * 3. Creator - 5 * 4. Handler - 7 */ $invalid_auth = 1; $authRole = Auth::user()->UserRoles->role; if ($authRole == 7 or $authRole == 1 or $authRole == 3) { $invalid_auth = 0; } if ($invalid_auth == 1) { Alert::error('Anda tidak memilik akses ini')->persistent('close'); return redirect('project/view/' . $id); } // End Check Authorization $db = Team::find($id_team); $db->status = 0; $db->save(); $now = date('Y-m-d'); foreach ($db->tl as $tl) { $db_tl = Teamleader::find($tl->id); $db_tl->status = 0; $db_tl->end = $now; $db_tl->save(); } foreach ($db->store as $store) { $db_st = Store::find($store->id); $db_st->status = 0; $db_st->save(); foreach ($store->members as $gm) { $db_gm = Member::find($gm->id); $db_gm->status = 0; $db_gm->end = $now; $db_gm->save(); foreach ($gm->get_users as $gu) { if ($gm->status == 1) { $db_em = Employee::find($gu->id); $db_em->status = 0; $db_em->save(); } } } } Alert::success('Berhasil menonaktifkan !')->persistent("Close"); return redirect('project/view/' . $id)->with('message', 'Stop Team Success!'); }
public function DelTeam($id, $id_team) { $db = Team::find($id_team); $db->status = 0; $db->save(); $now = date('Y-m-d'); foreach ($db->tl as $tl) { $db_tl = Teamleader::find($tl->id); $db_tl->status = 0; $db_tl->end = $now; $db_tl->save(); } foreach ($db->store as $store) { $db_st = Store::find($store->id); $db_st->status = 0; $db_st->save(); foreach ($store->members as $gm) { $db_gm = Member::find($gm->id); $db_gm->status = 0; $db_gm->end = $now; $db_gm->save(); foreach ($gm->get_users as $gu) { if ($gm->status == 1) { $db_em = Employee::find($gu->id); $db_em->status = 0; $db_em->save(); } } } } Alert::success('Berhasil menonaktifkan !')->persistent("Close"); return redirect('project/view/' . $id)->with('message', 'Stop Team Success!'); }