Exemple #1
0
 /**
  * Finds the Todo model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Todo the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Todo::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function getDeleted()
 {
     return Todo::onlyTrashed()->orderBy('deleted_at', 'desc')->get();
 }
 public function fooAction()
 {
     $list = Todo::find();
     $this->view->todoList = $list;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $todo = Todo::find($id);
     $todo->delete();
     return redirect()->route('admin.todos.index')->with('message', 'Se ha eliminado ' . $todo->name . ' de forma correcta.');
 }
Exemple #5
0
 private function _indexList()
 {
     $userId = \Yii::$app->user->id;
     $key = $this->getParam('key', 1);
     $sort = $this->getParam('order');
     $start = $this->getParam('start', 1);
     $pageSize = $this->getParam('length', 10);
     $columns = $this->getParam('columns');
     switch ($key) {
         case 0:
             $startDate = $this->getParam('startDate', date('Y-m-d'));
             $endDate = $this->getParam('endDate', date('Y-m-d'));
             $andWhere = ['and', ['>=', 'todo_date', $startDate], ['<=', 'todo_date', $endDate]];
             break;
         case 1:
             $andWhere = ['todo_date' => date('Y-m-d')];
             break;
         case 2:
             $andWhere = ['todo_date' => date('Y-m-d', strtotime('-1 day'))];
             break;
         case 3:
             $andWhere = ['>=', 'todo_date', date('Y-m-d', strtotime('this week'))];
             break;
         case 4:
             $andWhere = ['and', ['>=', 'todo_date', date('Y-m-d', strtotime('last week'))], ['<', 'todo_date', date('Y-m-d', strtotime('this week'))]];
             break;
         case 5:
             $andWhere = ['>=', 'todo_date', date('Y-m-01')];
             break;
         case 6:
             $andWhere = ['and', ['>=', 'todo_date', date('Y-m-01', strtotime('-1 month'))], ['<', 'todo_date', date('Y-m-01')]];
             break;
         case 7:
             $season = ceil(date('n') / 3);
             $andWhere = ['>=', 'todo_date', date('Y-m-d', mktime(0, 0, 0, $season * 3 - 3 + 1, 1, date('Y')))];
             break;
         case 8:
             $andWhere = ['>=', 'todo_date', date('Y-01-01')];
             break;
         case 9:
             $andWhere = ['or', ['todo_date' => ''], ['todo_date' => null]];
             break;
         case 10:
             $andWhere = ['todo_status' => [Todo::STATUS_WAIT, Todo::STATUS_DOING]];
             break;
         case 11:
             $andWhere = '1=1';
             break;
         default:
             $andWhere = '1=1';
     }
     $order = $columns[$sort[0]['column']]['name'];
     $asc = $sort[0]['dir'] == 'asc' ? SORT_ASC : SORT_DESC;
     $list = Todo::find()->where(['todo_account' => $userId])->andWhere($andWhere)->offset($start)->limit($pageSize)->orderBy([$order => $asc])->asArray()->all();
     $total = Todo::find()->where(['todo_account' => $userId])->andWhere($andWhere)->count();
     echo Json::encode(['recordsTotal' => $total, 'recordsFiltered' => $total, 'data' => $list]);
 }
 public function todoEmail(Request $request)
 {
     if ($request->input('emailMe') == "on") {
         $todoList1 = Todo::where('user_id', Auth::User()->id)->where('date_deleted', "0000-00-00 00:00:00")->where('date_archieved', "0000-00-00 00:00:00")->get();
         $mailData = ['todoList' => $todoList1];
         $userEmail = Auth::User()->email;
         Mail::send('emails.todolist', $mailData, function ($message) use($userEmail) {
             $message->to($userEmail)->subject('Your Todo List Digest');
         });
     }
     return dd($request->input());
 }