/** * Signs user up. * * @return User|null the saved model or null if saving fails */ public function signup() { if ($this->validate()) { $user = new Members(); $user->username = $this->username; $user->email = $this->email; $user->setPassword($this->password); $user->display_name = $this->display_name; $user->generateAuthKey(); $user->role_id = '2'; $user->avatar = 'uploads/default.jpg'; $user->status = '10'; if ($user->save()) { return $user; } } return null; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Members::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'regdate' => $this->regdate, 'customerID' => $this->customerID]); $query->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'uname', $this->uname])->andFilterWhere(['like', 'pass', $this->pass]); return $dataProvider; }
/** * Finds the Members model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Members the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Members::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $members = Members::find($id); $members->delete(); // redirect Session::flash('message', 'Berhasil Menghapus Data!'); return Redirect::to('members'); }
/** * Displays a single Projects model. * @param string $id * @return mixed */ public function actionView($id) { $dataProviderForMember = new ActiveDataProvider(['query' => Members::find()]); return $this->render('view', ['model' => $this->findModel($id), 'dataProviderForMember' => $dataProviderForMember]); }