Exemplo n.º 1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $list = Todolist::findOrFail($id);
     $categories = Category::lists('name', 'id')->all();
     $selected_categories = $list->categories()->lists('id')->all();
     return view('lists.edit')->with(compact('list', 'categories', 'selected_categories'));
 }
Exemplo n.º 2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $list = Todolist::findOrFail($id);
     return view('lists.show', compact('list'));
 }
Exemplo n.º 3
0
 /**
  * Delete a list
  * @param  integer $id The list ID
  * @return Response
  */
 public function destroy($id)
 {
     $user = \Auth::user();
     $list = Todolist::findOrFail($id);
     $list->delete();
     return \Redirect::route('lists.index')->with('message', 'Task deleted!');
 }
Exemplo n.º 4
0
 /**
  * Toggle task completion
  *
  * @param  integer $listId The list ID
  * @param  integer $taskId The task ID
  * @return  Response
  *
  */
 public function complete($listId, $taskId)
 {
     $user = User::find(\Auth::id());
     $list = Todolist::findOrFail($listId);
     if ($user->owns($listId)) {
         $task = $list->tasks()->where('id', '=', $taskId)->first();
         if ($task->done == true) {
             $task->done = false;
         } else {
             $task->done = true;
         }
         $task->save();
         return \Redirect::route('lists.show', [$list->id])->with('message', 'Task updated!');
     } else {
         return \Redirect::route('home')->with('message', 'Authorization error: you do not own this list.');
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $list = Todolist::findOrFail($id);
     return view('lists.show')->with('list', $list);
 }