/**
  * 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]);
 }
Example #2
0
 private static function AddValueToStatistic($value, $statistic_name)
 {
     $statistic = Statistic::where('name', $statistic_name)->first();
     if (!$statistic) {
         Log::critical(array('method' => __METHOD__, 'value' => $value, 'name' => $statistic_name));
         return;
     }
     $statistic->value = $statistic->value + $value;
     $statistic->save();
 }
 public function delete(Request $request)
 {
     $this->validate($request, ['task_id' => 'required|numeric']);
     $task_id = $request->input('task_id');
     $task = Task::where('id', $task_id)->where('deleted', false)->where('user_id', Auth::user()->id)->first();
     if (!$task) {
         abort(404);
     }
     $task->deleted = true;
     $pass = $task->save();
     $this->clearCache($task);
     if ($pass) {
         Alert::setSuccessAlert(Lang::get('app.deleted_task'));
     } else {
         Log::alert(__METHOD__ . '(' . __FILE__ . ')', array('task_id' => $task->id, 'user_id' => Auth::user()->id));
         Alert::setErrorAlert(Lang::get('app.unknown_error'));
     }
     Statistic::SubTask();
     return redirect()->action('UserController@tasks');
 }
Example #4
0
 function getHotViews($num)
 {
     $model = new Statistic();
     return $model->getTop($num);
 }
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     Statistic::AddUser();
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }