/**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $nowDateMinusWeek = date('Y-m-d', strtotime("-1 week")) . ' 00:00:00';
     $tasks = Task::where('deleted', false)->where('created_at', '>=', $nowDateMinusWeek)->orderBy('created_at', 'desc')->paginate(15);
     Task::resolveTasksDependencies($tasks);
     $statistics = Statistic::all();
     $statistics_array = array('users' => $statistics[0]->value, 'tasks' => $statistics[1]->value, 'solutions' => $statistics[2]->value);
     return view('home/index', ['tasks' => $tasks, 'statistics' => $statistics_array]);
 }
 public function search(Request $request = null, $paginate = 15)
 {
     $string = $request->input('s');
     $tasks = Task::where('deleted', false);
     if (!empty($string)) {
         if (is_numeric($string)) {
             $tasks = $tasks->where('id', $string);
         } else {
             $tasks = $tasks->where(function ($query) use($string) {
                 $query->where('author', 'LIKE', '%' . $string . '%')->orWhere('name', 'LIKE', '%' . $string . '%')->orWhere('description', 'LIKE', '%' . $string . '%');
             });
         }
         $tasks = $tasks->orderBy('created_at', 'desc')->paginate($paginate);
         Task::resolveTasksDependencies($tasks);
     } else {
         $tasks = null;
     }
     return view('task/search', ['tasks' => $tasks, 'search' => $string, 'alias' => null]);
 }
 public function tasks()
 {
     $user_id = Auth::user()->id;
     $tasks = Task::where('user_id', $user_id)->where('deleted', false)->orderBy('created_at', 'desc')->paginate(15);
     Task::resolveTasksDependencies($tasks);
     return view('user/tasks', ['tasks' => $tasks]);
 }