/**
  * Remove the specified resource from storage.
  *
  * @param  int $groupId
  * @param  int $employeeId
  * @return \Illuminate\Http\Response
  */
 public function destroy($groupId, $employeeId)
 {
     //
     $employee = Employee::findOrFail($employeeId);
     $this->authorize($employee);
     $group = Group::findOrFail($groupId);
     if (!$employee->belongsToGroup($group)) {
         return Response::json(['error' => 'employId <> groupId'], 404);
     }
     $employee->groups()->detach($groupId);
     return $group->employees;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param int $groupId
  * @param int $meetingId
  * @param int $timeslotId
  * @return mixed
  */
 public function destroy($groupId, $meetingId, $timeslotId)
 {
     $group = Group::findOrFail($groupId);
     $this->authorize($group);
     $meeting = Meeting::findOrFail($meetingId);
     $this->authorize($meeting);
     if ($meeting->start_time != NULL) {
         return Response::json(['error' => 'the meeting is already planned'], 422);
     }
     $timeslot = MeetingTimeslot::findOrFail($timeslotId);
     $this->authorize($timeslot);
     if ($meeting->group_id == $groupId && $timeslot->meeting_id == $meetingId) {
         $timeslot->delete();
         return $timeslot;
     }
     return Response::json(['error' => 'meeting->group_id <> groupId || timeslot->meeting_id <> meetingId'], 403);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param int $groupId
  * @param int $meetingId
  * @return mixed
  */
 public function destroy($groupId, $meetingId)
 {
     $group = Group::findOrFail($groupId);
     $this->authorize($group);
     $meeting = Meeting::findOrFail($meetingId);
     $this->authorize($meeting);
     $meeting->delete();
     return $meeting;
 }
Example #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $group = Group::findOrFail($id);
     $this->authorize($group);
     $group->delete();
     return $group;
 }