Exemplo n.º 1
0
 public function add(Requests\StoreTaskRequest $request)
 {
     $request->user()->tasks()->create(['todo_list_id' => $request->todo_list_id, 'description' => $request->description]);
     return redirect('/lists/' . $request->todo_list_id . '?page=' . $request->get('page'))->with('success', 'The task has been added successfully');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(StoreTaskRequest $request, $id)
 {
     $output = Task::find($id);
     // If the user is not an Admin, only show his own tasks
     if (!Auth::user()->is_admin && Auth::user()->id != $output->user_id) {
         $message = 'Error! Unable to edit task with id "' . $id . '"';
         return \Redirect::route('tasks.index')->with(['status' => $message]);
     }
     // get this task
     $task = Task::where('id', $id)->update($request->except(['_method', '_token']));
     $message = 'Task with id "' . $id . '" updated';
     return \Redirect::route('tasks.index')->with(['status' => $message]);
 }
Exemplo n.º 3
0
 public function store(StoreTaskRequest $request)
 {
     $request->user()->tasks()->create(['name' => $request['name']]);
     return redirect('/tasks')->with('status', trans('tasks.messages.created'));
 }