/**
  * Update the specified resource in storage.
  * @param type int $id
  * @param type Group_assign_department $group_assign_department
  * @param type Department $department
  * @param type DepartmentUpdate $request
  * @return type Response
  */
 public function update($id, Group_assign_department $group_assign_department, Department $department, DepartmentUpdate $request)
 {
     try {
         $table = $group_assign_department->where('department_id', $id);
         $table->delete();
         $requests = $request->input('group_id');
         // foreach ($requests as $req) {
         // DB::insert('insert into group_assign_department (group_id, department_id) values (?,?)', [$req, $id]);
         // }
         $departments = $department->whereId($id)->first();
         if ($departments->fill($request->except('group_access'))->save()) {
             return redirect('departments')->with('success', 'Department Updated sucessfully');
         } else {
             return redirect('departments')->with('fails', 'Department not Updated');
         }
     } catch (Exception $e) {
         return redirect('departments')->with('fails', 'Department not Updated');
     }
 }
Exemplo n.º 2
0
 /**
  * Remove the specified resource from storage.
  * @param type int $id
  * @param type Groups $group
  * @param type Group_assign_department $group_assign_department
  * @return type Response
  */
 public function destroy($id, Groups $group, Group_assign_department $group_assign_department)
 {
     $users = User::where('assign_group', '=', $id)->first();
     if ($users) {
         $user = '******';
         return redirect('groups')->with('fails', 'Group cannot Delete ' . $user);
     }
     $group_assign_department->where('group_id', $id)->delete();
     $groups = $group->whereId($id)->first();
     /* Check whether function success or not */
     try {
         $groups->delete();
         /* redirect to Index page with Success Message */
         return redirect('groups')->with('success', 'Group Deleted Successfully');
     } catch (Exception $e) {
         /* redirect to Index page with Fails Message */
         return redirect('groups')->with('fails', 'Groups cannot Create' . '<li>' . $e->errorInfo[2] . '</li>');
     }
 }
Exemplo n.º 3
0
 /**
  * Remove the specified resource from storage.
  * @param type int $id
  * @param type Groups $group
  * @param type Group_assign_department $group_assign_department
  * @return type Response
  */
 public function destroy($id, Groups $group, Group_assign_department $group_assign_department)
 {
     try {
         $group_assign_department->where('group_id', $id)->delete();
         $groups = $group->whereId($id)->first();
         /* Check whether function success or not */
         if ($groups->delete() == true) {
             /* redirect to Index page with Success Message */
             return redirect('groups')->with('success', 'Group Deleted Successfully');
         } else {
             /* redirect to Index page with Fails Message */
             return redirect('groups')->with('fails', 'Group can not Delete');
         }
     } catch (Exception $e) {
         /* redirect to Index page with Fails Message */
         return redirect('groups')->with('fails', 'Groups can not Create');
     }
 }