/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Register $Register, Request $request) { $validator = $this->validate($request, ['name' => 'required', 'password' => 'required|min:8', 'email' => 'required|email|unique:users']); $messages = $validator->messages(); dd($messages); $Register->create($request->all()); return redirect()->route('home'); }
public function actionCreate() { $model = new Register(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['confirmation']); } else { return $this->render('create', ['model' => $model]); } }
public function actionRegister() { $model = new Register(); $profile = new Profile(); if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { if ($id = $model->register()) { $profile->createProfile($id); return $this->goHome(); } } } return $this->render('register', ['model' => $model]); }
public function actionDelete_register($id) { $model = Register::findOne($id); if ($model->delete()) { return $this->redirect(['register/view_register']); } else { echo 'delete fail...'; } }
public function updateTableActions(Request $request) { $hash = $request->get('user-hash'); if ($request->get('action') == 'delete') { $user = User::where('hash', $hash)->first(); $user_toregister = Register::where('hash', $hash)->first(); if ($user) { if ($user->delete()) { flash()->success('Συγχαρητήρια', 'ο χρήστης διεγράφη με επιτυχία'); } else { flash()->error('Προσοχή!', 'ο χρήστης ΔΕΝ διεγράφει'); } } elseif ($user_toregister) { if ($user_toregister->delete()) { flash()->success('Συγχαρητήρια', 'ο χρήστης διεγράφη με επιτυχία'); } else { flash()->error('Προσοχή!', 'ο χρήστης ΔΕΝ διεγράφει'); } } } return 'true'; }
/** * ************ @var profile save and Update *******/ public function profileSave($data) { /************* get Query User table *******/ $user = User::findOne(Yii::$app->user->id); $Id = $user['id']; $uId = $user['uId']; $MemId = $user['MemId']; /************* get Query Register table *******/ $userInfo = Register::find()->where(['uid' => $uId])->one(); $Id = $userInfo['id']; if ($userInfo) { $userInfo->firstname = $data['Register']['firstname']; $userInfo->middlename = $data['Register']['middlename']; $userInfo->lastname = $data['Register']['lastname']; $userInfo->email = $data['Register']['email']; $userInfo->city = $data['Register']['city']; $userInfo->state = $data['Register']['state']; $userInfo->country = $data['Register']['country']; $userInfo->zip = $data['Register']['zip']; $userInfo->secondLanguage = $data['Register']['secondLanguage']; $userInfo->thirdLanguage = $data['Register']['thirdLanguage']; $userInfo->address = $data['Register']['address']; $userInfo->address2 = $data['Register']['address2']; $userInfo->dob = $data['Register']['dob']; /************* Update Query *******/ $command = Yii::$app->db->createCommand("UPDATE register SET\n\t\t\t\t \t\t\tfirstname ='{$userInfo->firstname}',\n\t\t\t\t \t\t\tmiddlename ='{$userInfo->middlename}',\n\t\t\t\t \t\t\tlastname ='{$userInfo->lastname}',\n\t\t\t\t \t\t\temail ='{$userInfo->email}',\n\t\t\t\t \t\t\tcity ='{$userInfo->city}',\n\t\t\t\t \t\t\tstate ='{$userInfo->state}',\n\t\t\t\t \t\t\tcountry ='{$userInfo->country}',\n\t\t\t\t \t\t\tzip ='{$userInfo->zip}',\n\t\t\t\t \t\t\tsecondLanguage ='{$userInfo->secondLanguage}',\n\t\t\t\t \t\t\tthirdLanguage ='{$userInfo->thirdLanguage}',\n\t\t\t\t \t\t\taddress ='{$userInfo->address}',\n\t\t\t\t \t\t\taddress2 ='{$userInfo->address2}',\n\t\t\t\t \t\t\tdob ='{$userInfo->dob}'\n\t\t\t\t \t\t\tWHERE id ='{$Id}'"); $command->execute(); return $userInfo; } else { $this->firstname = $data['UserprofileForm']['firstname']; $this->lastname = $data['UserprofileForm']['lastname']; $this->middlename = $data['UserprofileForm']['middlename']; $this->email = $data['UserprofileForm']['email']; $this->city = $data['UserprofileForm']['city']; $this->state = $data['UserprofileForm']['state']; $this->country = $data['UserprofileForm']['country']; $this->zip = $data['UserprofileForm']['zip']; $this->secondLanguage = $data['UserprofileForm']['secondLanguage']; $this->thirdLanguage = $data['UserprofileForm']['thirdLanguage']; $this->address = $data['UserprofileForm']['address']; $this->address2 = $data['UserprofileForm']['address2']; $this->dob = $data['UserprofileForm']['dob']; /************* Insert Query Into Register table *******/ $data = Yii::$app->db->createCommand()->insert('register', ['firstname' => $this->firstname, 'lastname' => $this->lastname, 'middlename' => $this->middlename, 'email' => $this->email, 'city' => $this->city, 'state' => $this->state, 'country' => $this->country, 'zip' => $this->zip, 'secondLanguage' => $this->secondLanguage, 'thirdLanguage' => $this->thirdLanguage, 'address' => $this->address, 'address2' => $this->address2, 'dob' => $this->dob, 'createdDate' => date("Y-m-d H:i:s"), 'id' => $Id, 'uId' => $uId, 'MemId' => $MemId])->execute(); return $data; } }