/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request, $id = Null) { $user = Auth::user(); // If the user is not an Admin, only show his own tasks if ($user->is_admin) { if ($request->is('*/user/*')) { $tasks = Task::where('user_id', $id)->get(); } elseif ($request->is('*/category/*')) { $tasks = Task::where('category_id', $id)->get(); } else { $tasks = Task::get(); } // also retrieve the trashed tasks $trashed = Task::onlyTrashed()->get(); } else { $tasks = Task::where('user_id', $user->id)->get(); // also retrieve the trashed tasks $trashed = Task::onlyTrashed()->get(); } $heading = 'My Tasks'; // return view('tasks', array('tasks' => $tasks, 'heading' => $heading, 'trashed' => $trashed)); }
public function deleted() { return Task::onlyTrashed()->get(); }
/** * Gets all trashed tasks * * @return \Illuminate\Http\Response */ public function getTrashed() { return response()->json(Task::onlyTrashed()->with('user', 'category')->get()); }
public function trash() { $tasks = Task::onlyTrashed()->get(); return view('tasks.trash', compact('tasks')); }