/**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     $actionid = $this->route('id');
     if (Auth::check()) {
         return Auth::user()->id == Action::find($actionid)->userId || User::find(Auth::id())->hasRole('bpLead') || User::find(Group::find(Action::find($actionid)->group)->user_ID)->id == Auth::id();
     } else {
         return false;
     }
 }
Esempio n. 2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     $action = Action::find($id);
     //return $gender;
     if (count($action) > 0) {
         $statusCode = 200;
         $response = ['id' => $action->id, 'Action' => $action->action];
     } else {
         $response = ["error" => "Action doesn`t exist"];
         $statusCode = 404;
     }
     return response($response, $statusCode)->header('Content-Type', 'application/json');
 }
 public function editTaskFromComments($id, Requests\EditTaskRequest $request)
 {
     $progress = ['0' => 'Not Started', '1' => 'In Progress', '2' => 'Done'];
     $model = new Task();
     $task = Task::findOrFail($id);
     $groups = Group::lists('name', 'id');
     $users = User::lists('name', 'id');
     $bpid = $model->getBpIdFromTask($id);
     $action = Action::find($task->action_id)->description;
     $names = explode(', ', $task->collaborators);
     $selectedUsers = array();
     $selectedGroups = array();
     foreach ($names as $name) {
         if (count(User::all()->where('name', $name)) > 0) {
             array_push($selectedUsers, User::all()->where('name', $name)->first()->id);
         }
         if (count(Group::all()->where('name', $name)) > 0) {
             array_push($selectedGroups, Group::all()->where('name', $name)->first()->id);
         }
     }
     return view('editTaskComments', compact('task', 'action', 'groups', 'users', 'bpid', 'selectedUsers', 'selectedGroups', 'progress'));
 }
Esempio n. 4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($project_id, $id)
 {
     $action = Action::find($id);
     $action->delete();
     flash()->success('Action has been successfully deleted!');
     return redirect()->action('ProjectsController@show', $project_id);
 }