Esempio n. 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ["txtName" => "required|unique:teams,name", 'staff' => 'required'], ["txtName.required" => "Please enter cate's name.", 'txt.unique' => 'This name has already been taken', 'staff.required' => 'Please select staff']);
     $team = new Manager();
     $team->name = $request->txtName;
     $team->created_user_id = Auth::user()->id;
     $team->save();
     foreach ($request->input('staff') as $key => $value) {
         $detail = new TeamDetail();
         $detail->team_id = $team->id;
         $detail->staff_id = $value;
         $detail->save();
     }
     return redirect()->route('admin.team.manager.index')->with('success', 'Posted completely!');
 }
Esempio n. 2
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $title = "Dashboard";
     if (Auth::user()->role_id == 4) {
         $model = Department::with(['user', 'developer', 'leader', 'manager'])->get();
         return view('html.dashboard.admin', compact('title', 'model'));
     } elseif (Auth::user()->role_id == 3) {
         return view('html.dashboard.manager', compact('title', 'model'));
     } elseif (Auth::user()->role_id == 2) {
         $list = \App\Team::where('created_user_id', Auth::user()->id)->with('detail')->first();
         return view('html.dashboard.leader', compact('title', 'list'));
     } else {
         $var = \App\TeamDetail::select('team_id')->where('staff_id', Auth::user()->id)->first();
         $bol = "";
         if ($var != null) {
             $team = \App\Team::find($var->team_id);
             $leader = User::find($team->created_user_id);
             $bol = "true";
             $list = \App\TeamDetail::select('*')->where('staff_id', '<>', Auth::user()->id)->where('team_id', $var->team_id)->get();
         }
         return view('html.dashboard.developer', compact('title', 'list', 'bol', 'leader'));
     }
 }
 public function getDelMember($id)
 {
     $staff = User::find($id);
     if (\Auth::user()->role_id == 1) {
         return view('html.error-403');
     }
     if ($staff->role_id == 4) {
         return view('html.error-403');
     }
     $teams = Team::where('created_user_id', $staff->id)->get();
     if (!empty($team)) {
         foreach ($teams as $key => $value) {
             TeamDetail::where('team_id', $value->id)->delete();
         }
         foreach ($teams as $key => $value) {
             $value->delete();
         }
     }
     $detail = TeamDetail::where('staff_id', $staff->id)->get();
     if (!empty($detail)) {
         foreach ($detail as $key => $value) {
             $value->delete();
         }
     }
     Profile::where('user_id', $staff->id)->first()->delete();
     $staff->delete();
     return redirect()->route('admin.index')->with('success', 'Deleted Successfully!!!');
 }
 public function clear()
 {
     if (!Request::input('checkbox')) {
         return redirect()->back()->with('danger', 'You forgot chosing items');
     }
     foreach (Request::input('checkbox') as $key => $value) {
         $staff = User::find($value);
         $teams = Team::where('created_user_id', $staff->id)->get();
         foreach ($teams as $key => $value) {
             TeamDetail::where('team_id', $value->id)->delete();
         }
         foreach ($teams as $key => $value) {
             $value->delete();
         }
         $detail = TeamDetail::where('staff_id', $staff->id)->get();
         foreach ($detail as $key => $value) {
             $value->delete();
         }
         Profile::where('user_id', $staff->id)->first()->delete();
         $staff->delete();
     }
     return redirect()->route('admin.index')->with('success', 'successfully deleted');
 }
 public function destroy($id, $user)
 {
     $team = Team::find($id);
     if ($team->created_user_id != Auth::user()->id) {
         return view('html.error-403');
     }
     \App\TeamDetail::where(['team_id' => $id, 'staff_id' => $user])->delete();
     return redirect()->route('admin.team.index')->with('success', 'successfully deleted');
 }
Esempio n. 6
0
 public function delete($id)
 {
     $list = TeamDetail::where('team_id', $id)->get();
     foreach ($list as $key => $value) {
         $value->delete();
     }
     Leader::find($id)->delete();
     return redirect()->route('admin.index')->with('success', 'successfully deleted');
 }
 public function clear(Request $request)
 {
     if (!$request->input('checkbox')) {
         return redirect()->back()->with('danger', 'You forgot chosing items');
     }
     foreach ($request->input('checkbox') as $key => $value) {
         $model = TeamDetail::find($value);
         $model->delete();
     }
     return redirect()->route('admin.team.index')->with('success', 'successfully deleted');
 }