/**
  * Creates a new Member model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Member();
     $model->generateAuthKey();
     $model->status = 10;
     $model->role_id = 1;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $model->setPassword($model->password_hash);
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
示例#2
0
 public function register(Request $request)
 {
     $validate = validateuser::validate(Request::all());
     if ($validate->passes()) {
         $user = new Member();
         $user->email = $request::input('email');
         $user->password = \Hash::make($request::input('password'));
         $user->name = $request::input('name');
         $user->surname = $request::input('surname');
         $user->nickname = $request::input('nickname');
         $user->phone = $request::input('phone');
         $user->id_card = $request::input('id_card');
         $user->bank = $request::input('bank');
         $user->account_no = $request::input('account');
         $user->education = $request::input('education');
         $user->institute = $request::input('institute');
         $user->reference = $request::input('reference');
         $link = '';
         if ($user->save()) {
             $userinfo = $request::only('email', 'password');
             if (Auth::attempt($userinfo)) {
                 $link = '/';
             }
             //ส่ง email
             //จบส่ง email
         } else {
             $link = 'register';
         }
         return Redirect::to($link);
     } else {
         return redirect::to('register')->withInput(Request::except('password'))->withErrors($validate->messages());
     }
 }
示例#3
0
 public function register(Request $request)
 {
     $validate = validateuser::validate(Request::all());
     //Generate validate code
     $validatecode = MD5(app('App\\Http\\Controllers\\Sendmail')->generateRandomString());
     if ($validate->passes()) {
         $input_birthday = explode("/", Request::input('birthday'));
         $birthday = $input_birthday[2] . "-" . $input_birthday[1] . "-" . $input_birthday[0];
         $user = new Member();
         $user->email = $request::input('email');
         $user->password = \Hash::make($request::input('password'));
         $user->name = $request::input('name');
         $user->surname = $request::input('surname');
         $user->nickname = $request::input('nickname');
         $user->phone = $request::input('phone');
         $user->id_card = $request::input('id_card');
         $user->birthday = $birthday;
         //$user->bank = $request::input('bank');
         //$user->account_no = $request::input('account');
         //$user->education = $request::input('education');
         //$user->institute = $request::input('institute');
         //$user->reference = $request::input('reference');
         //$user->address = $request::input('address');
         //$user->province = $request::input('province');
         /*if($request::input('province') != 69){
             $user->district = 0;
           }else{
             $user->district = $request::input('district');
           }*/
         $user->userstatus = 1;
         $user->permission = 1;
         $user->validate = 1000;
         $user->email_valid_code = $validatecode;
         $link = '';
         if ($user->save()) {
             $userinfo = $request::only('email', 'password');
             if (Auth::attempt($userinfo)) {
                 $link = 'poatregister';
             }
             //ส่ง email
             Sendverify::sendEmailReminder($request::input('name') . " " . $request::input('surname'), $request::input('email'), $validatecode);
             //จบส่ง email
         } else {
             $link = 'register';
         }
         //ตรวจสอบสถาบันว่ามีไหมถ้าไม่มีให้เพิ่มไป
         /*$countinstitute = institute::where('name', 'LIKE', $request::input('institute'))->count();
         
                     if($countinstitute < 1){
                         $institute = new institute();
                         $institute->name = $request::input('institute');
                         $institute->save();
                     }*/
         //จบตรวจสอบสถาบันว่ามีไหมถ้าไม่มีให้เพิ่มไป
         return Redirect::to($link);
     } else {
         return redirect::to('register')->withInput(Request::except('password'))->withErrors($validate->messages());
     }
 }
示例#4
0
 public function actionView($id = 0)
 {
     $this->layout = false;
     if ($id) {
         $member = Member::findOne($id);
         if ($member !== null) {
             //编辑场景
             $member->setScenario('update');
         } else {
             return '未找到数据~';
         }
     } else {
         $member = new Member();
         //注册场景
         $member->setScenario('register');
     }
     //Post提交
     if (Yii::$app->request->getIsPost()) {
         $member->setAttributes(Yii::$app->request->post());
         $member->photo = UploadedFile::getInstanceByName('photo');
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         if ($member->validate()) {
             //通过验证
             /**
              * 判断是否选择了文件上传
              * 如果未通过注销当前attributes,这里主要是兼容update场景
              */
             if ($member->photo) {
                 if (!file_exists('uploads/')) {
                     mkdir('uploads/', '777');
                 }
                 $filename = time() . '.' . $member->photo->extension;
                 $member->photo->saveAs('uploads/' . $filename);
                 $member->photo = 'uploads/' . $filename;
             } else {
                 unset($member->photo);
             }
             $result = $member->save();
             if ($result) {
                 Yii::$app->response->data = ['status' => 200, 'message' => '保存成功'];
             } else {
                 Yii::$app->response->data = ['status' => 202, 'message' => '保存失败'];
             }
         } else {
             //验证未通过
             Yii::$app->response->data = ['status' => 201, 'message' => $member->getErrors()];
         }
         return;
     }
     //创建视图
     return $this->render('view', ['user' => $member]);
 }
示例#5
0
 public function prosesRegister()
 {
     $member = new Member();
     $member->MemberName = $_POST['name'];
     $member->MemberEmail = $_POST['email'];
     $member->MemberAddress = $_POST['address'];
     $member->MemberPhone = $_POST['phone'];
     $member->MemberPassword = $_POST['password'];
     $member->MemberRegisterDate = Carbon::now();
     $member->MemberExpiredDate = new Carbon('next year');
     $member->save();
     header('Location: ' . base);
 }
示例#6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make(Request::all(), ['name' => 'required']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator->errors());
     } else {
         try {
             $person = new Person();
             $person->name = Input::get('name');
             $person->last_name = Input::get('last_name');
             $person->document = Input::get('document') == '' ? null : Input::get('document');
             $person->identity = Input::get('identity') == '' ? null : Input::get('identity');
             $person->email = Input::get('email') == '' ? null : Input::get('email');
             $person->birthdate = Input::get('birthdate');
             $person->nationality = Input::get('nationality');
             $person->gender = Input::get('gender');
             $person->phone = Input::get('phone');
             $person->phone_cel = Input::get('phone_cel');
             $person->name = Input::get('name');
             $person->name = Input::get('name');
             $person->save();
             $member = new Member();
             $member->father = Input::get('father');
             $member->mother = Input::get('mother');
             $member->marital_status_id = Input::get('marital_status_id');
             $member->date_baptism = Input::get('date_baptism');
             $member->occupacion = Input::get('occupacion');
             $member->function_id = Input::get('function_id');
             $member->literacy_id = Input::get('literacy_id');
             $member->person_id = $person->id;
             $member->save();
             $address = new Address();
             $address->address = Input::get('address');
             $address->number = Input::get('number');
             $address->complement = Input::get('complement');
             $address->zip_code = Input::get('zip_code');
             $address->reference = Input::get('reference');
             $address->country = Input::get('country');
             $address->state = Input::get('state');
             $address->city = Input::get('city');
             $address->person_id = $person->id;
             $address->save();
             return redirect('members');
         } catch (\Illuminate\Database\QueryException $e) {
             print_r($e->errorInfo);
         }
     }
 }
示例#7
0
 /**
  * Creates a new Member model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Member();
     $form = new UploadForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($form->image = UploadedFile::getInstance($form, 'image')) {
             $model->pic = 'image/' . md5($_SERVER['REQUEST_TIME'] . $form->image->baseName) . $_SERVER['REQUEST_TIME'] . '.' . $form->image->extension;
             $form->image->saveAs($model->pic);
             $model->save();
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             $form->addError('image', '图片不可为空');
         }
     }
     return $this->render('create', ['model' => $model, 'uploadForm' => $form]);
 }
 public function actionRegister()
 {
     $member = new Member();
     if (!empty($_POST)) {
         $member->name = $_POST['Member']['name'];
         $member->username = $_POST['Member']['username'];
         $member->password = $_POST['Member']['password'];
         if ($member->save()) {
             $session = new Session();
             $session->open();
             $session->setFlash('message', 'Register Success.');
             return $this->redirect(['registersuccess']);
         }
     }
     return $this->render('//Frontend/Register', ['member' => $member]);
 }
示例#9
0
 public function actionRegister()
 {
     $email = $_REQUEST['email'];
     $passwd = md5($_REQUEST['password']);
     $memeber_type = $_REQUEST['member_type'];
     $member_name = $_REQUEST['member_name'];
     $member_phone = $_REQUEST['member_phone'];
     $model = new Member();
     $model->email = $email;
     $model->password = $passwd;
     $model->member_type = $memeber_type;
     $model->member_name = $member_name;
     $model->member_phone = $member_phone;
     if ($model->save()) {
         $arr = $model->find()->where(['email' => $email])->asArray()->one();
         $res = array('code' => '10200', 'mess' => 'success', 'stat' => '200', 'data' => $arr);
     } else {
         $res = array('code' => '10204', 'mess' => 'The request is error', 'stat' => '100', 'data' => "");
     }
     exit(json_encode($res));
 }
示例#10
0
 /**
  * Creates a new Project model.
  * If creation is successful, the browser will be redirected to the 'overview' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Project();
     $model->loadDefaultValues();
     if ($model->load(Yii::$app->request->post())) {
         $image = UploadedFile::getInstance($model, 'image');
         if (!is_null($image)) {
             // store the source file name
             $model->logoname = $image->name;
             $ext = end(explode(".", $image->name));
             // generate a unique file name
             $model->logo = Yii::$app->security->generateRandomString() . ".{$ext}";
             $path = Yii::$app->basePath . '/web/uploads/' . $model->logo;
         }
         if ($model->save()) {
             if (!is_null($image)) {
                 $image->saveAs($path);
             }
             $member = new Member();
             $member->setAttribute('project_id', $model->id);
             $member->setAttribute('user_id', Yii::$app->user->id);
             $member->setAttribute('role', 'Administrator');
             $member->save();
             return $this->redirect(['overview', 'identifier' => $model->identifier]);
         } else {
             Yii::$app->getSession()->setFlash('danger', Yii::t('app', 'Something went wrong and the settings was not saved.'));
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
示例#11
0
 public function adminUpdate(Member $member, $input)
 {
     $member->fullname = $input['fullname'];
     $member->usermail = $input['usermail'];
     $member->mobile = $input['mobile'];
     $member->address = $input['address'];
     $member->status = $input['status'];
     if ($member->save()) {
         return $member;
     } else {
         return false;
     }
 }
示例#12
0
 /**
  * Updates Member into database
  *
  * @param Member $member
  * @param array $input
  *
  * @return Member
  */
 public function update($member, $input)
 {
     $member->fill($input);
     $member->save();
     return $member;
 }
示例#13
0
 public static function makeFriends(self $member1, self $member2, $save = false)
 {
     $member1->_mergeFriends([$member2->_id]);
     $member2->_mergeFriends([$member1->_id]);
     return !$save || $member1->save() && $member2->save();
 }