示例#1
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search($params)
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $query = Accounts::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $criteria->compare('id', $this->id, true);
     $criteria->compare('text', $this->text, true);
     return new CActiveDataProvider($this, array('criteria' => $criteria));
 }
示例#2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $input = Input::all();
     $rules = array('account_name' => 'required');
     $messages = array('account_name.required' => 'Please enter the account name !');
     $validation = Validator::make($input, $rules, $messages);
     if ($validation->passes()) {
         $accounts = Accounts::find($id);
         $accounts->account_name = Input::get('account_name');
         //$accounts->manager_id  =  Session::get('manager_id');
         $accounts->save();
         return Redirect::to('/accounts/');
     } else {
         return Redirect::to('/accounts/' . $id . '/edit')->withErrors($validation);
     }
 }
 public function listAction()
 {
     $list = Accounts::find();
     $this->view->disable();
     echo json_encode(array("data" => $list->toArray()));
 }