Beispiel #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Profile::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;
     }
     if ($this['directions'] != '') {
         $query->join("inner join", "psychologist_directions", "psychologist_directions.psychologist_id=profile.user_id");
         $query->andOnCondition("psychologist_directions.direction_id in ('" . $this['directions'] . "')");
     }
     if ($this['problems'] != '') {
         $query->join("inner join", "psychologist_problems", "psychologist_problems.psychologist_id=profile.user_id");
         $query->andOnCondition("psychologist_problems.problem_id in ('" . $this['problems'] . "')");
     }
     if ($this['pricef'] != '') {
         $query->andOnCondition('price >= ' . $this->pricef);
     }
     if ($this['pricet'] != '') {
         $query->andOnCondition('price <= ' . $this->pricet);
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'has_diplom' => $this->has_diplom, 'city_id' => $this->city_id, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'secondname', $this->secondname])->andFilterWhere(['like', 'education', $this->education])->andFilterWhere(['like', 'experience', $this->experience])->andFilterWhere(['=', 'gender', $this->gender]);
     return $dataProvider;
 }
Beispiel #2
0
 public function actionUpdateProfile()
 {
     if (!Yii::$app->user->isGuest) {
         if (Yii::$app->request->get('new')) {
             $model = new Profile();
             $avatar = "";
             $user_id = Yii::$app->user->id;
         } else {
             if (Yii::$app->request->get('id')) {
                 $user_id = Yii::$app->request->get('id');
             } else {
                 $user_id = Yii::$app->user->id;
             }
             $model = Profile::find()->where(['user_id' => $user_id])->one();
             if (!empty($model->avatar)) {
                 $avatar = $model->avatar;
             }
         }
         if (Yii::$app->request->post()) {
             $model->user_id = $user_id;
             $model->first_name = Yii::$app->request->post('Profile')['first_name'];
             $model->second_name = Yii::$app->request->post('Profile')['second_name'];
             $model->last_name = Yii::$app->request->post('Profile')['last_name'];
             $model->birthday = Yii::$app->request->post('Profile')['birthday'];
             $model->about = Yii::$app->request->post('Profile')['about'];
             $model->location = Yii::$app->request->post('Profile')['location'];
             $model->sex = Yii::$app->request->post('Profile')['sex'];
             $upload = new UploadForm();
             if ($upload->imageFiles = UploadedFile::getInstances($model, 'avatar')) {
                 if (!empty($avatar)) {
                     if (file_exists(Yii::getAlias('@webroot/uploads/image_profile/original/' . $avatar))) {
                         unlink(Yii::getAlias('@webroot/uploads/image_profile/original/' . $avatar));
                         unlink(Yii::getAlias('@webroot/uploads/image_profile/xm/' . $avatar));
                         unlink(Yii::getAlias('@webroot/uploads/image_profile/sm/' . $avatar));
                         unlink(Yii::getAlias('@webroot/uploads/image_profile/lm/' . $avatar));
                     }
                 }
                 $filename = $upload->upload('image_profile/');
                 $model->avatar = $filename[0] . '.' . $upload->imageFiles[0]->extension;
             } else {
                 $model->avatar = $avatar;
             }
             if ($model->save()) {
                 Yii::$app->session->setFlash('success', "Профиль изменен");
                 return $this->redirect(['/user/view-profile', 'id' => $user_id]);
             } else {
                 Yii::$app->session->setFlash('error', "Не удалось изменить профиль");
                 Yii::error('Ошибка записи. Профиль не изменен');
                 return $this->refresh();
             }
         } else {
             return $this->render('update-profile', ['model' => $model]);
         }
     } else {
         Yii::$app->session->setFlash('error', 'Нет доступа!');
         return $this->redirect('/');
     }
 }
 protected function findModelRegion($region_id)
 {
     $modelProfile = Profile::find()->where(['id' => $region_id])->one();
     if ($modelProfile !== null) {
         return $modelProfile;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #4
0
 /**
  * @param $id
  * @return mixed
  */
 public function acceptAddRequest($id)
 {
     $profile = Profile::find($id);
     $res = $profile->apartments()->defaultapartment()->first();
     //        $profile->apartments()->updateExistingPivot($res , ['approved' => '1']);
     $profile->apartments()->detach($res);
     $profile->apartments()->attach($res, ['approved' => '1']);
     $profile->defaultApartment = Auth::user()->profile->defaultApartment;
     // set new added apartment as default
     $profile->save();
     return redirect()->back()->withMessage('User Approved')->withStatus('success');
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Profile::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, 'active' => $this->active]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'category', $this->category]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Profile::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(['user_id' => $this->user_id]);
     $query->andFilterWhere(['like', 'birthday', $this->birthday])->andFilterWhere(['like', 'nickname', $this->nickname])->andFilterWhere(['like', 'created_at', $this->created_at])->andFilterWhere(['like', 'avatar', $this->avatar])->andFilterWhere(['like', 'updated_at', $this->updated_at])->andFilterWhere(['like', 'background_img', $this->background_img]);
     return $dataProvider;
 }
Beispiel #7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Profile::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(['user_id' => $this->user_id, 'gender' => $this->gender]);
     $query->andFilterWhere(['like', 'avatar', $this->avatar])->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'second_name', $this->second_name])->andFilterWhere(['like', 'middle_name', $this->middle_name])->andFilterWhere(['like', 'birthday', $this->birthday])->andFilterWhere(['like', 'profile_status', $this->profile_status]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Profile::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, 'user_id' => $this->user_id]);
     $query->andFilterWhere(['like', 'worker_name', $this->worker_name])->andFilterWhere(['like', 'telephone', $this->telephone])->andFilterWhere(['like', 'head_position', $this->head_position])->andFilterWhere(['like', 'head_name', $this->head_name]);
     return $dataProvider;
 }
Beispiel #9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Profile::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['user_id' => $this->user_id, 'state_id' => $this->state_id]);
     return $dataProvider;
 }
 public function actionUpdate()
 {
     $model = Profile::find()->where('user_id = ' . Yii::$app->user->id)->one();
     if ($model->load(Yii::$app->request->post(), '')) {
         $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
         if ($model->uploadImage() && $model->save(false)) {
             return $model;
         } else {
             throw new ServerErrorHttpException('Failed to update the object for unknown reason.');
         }
     } else {
         throw new ServerErrorHttpException('Failed to update the object for unknown reason.');
     }
     return $model;
 }
Beispiel #11
0
 /**
  * Delete a Guest of a Room.
  *
  * @param  Request  $request
  * @param  int  $rid
  * @param  int  $pid
  * @return Response
  */
 public function destroy(Request $request, $rid, $pid)
 {
     try {
         $room = Room::find($rid);
         if (!$room) {
             return response()->error(404, 'Room Not Found');
         }
         $profile = Profile::find($pid);
         if (!$profile) {
             return response()->error(404, 'Profile Not Found');
         }
         $room->guests()->detach($profile);
         $room->decrement('guest_count');
         return response()->success();
     } catch (Exception $e) {
         return response()->error($e);
     }
 }
Beispiel #12
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // ---------------------------------------------------------------------
     // CONFERENCE 1
     // ---------------------------------------------------------------------
     $faker = Faker::create();
     $user = Sentinel::findById(6);
     $conference = Conference::find(1);
     $countries = ['Canada', 'France', 'India', 'United States'];
     $genders = ['female', 'male'];
     for ($i = 0; $i < 100; ++$i) {
         $profile = ['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'city' => $faker->city, 'country' => $countries[rand(0, 3)], 'birthdate' => $faker->date($format = 'Y-m-d', $max = 'now'), 'gender' => $genders[rand(0, 1)]];
         $profile = new Profile($profile);
         $profile->user()->associate($user);
         $profile->save();
         $profile->conferences()->attach($conference->id, ['birthdate' => $profile->birthdate, 'country' => $profile->country, 'gender' => $profile->gender, 'status' => 'approved']);
         $conference->increment('attendee_count');
     }
     // ---------------------------------------------------------------------
     // CONFERENCE 2
     // ---------------------------------------------------------------------
     $conference = Conference::find(2);
     $event = $conference->events()->first();
     $room = $conference->accommodations()->first()->rooms()->first();
     $conferenceVehicle = $conference->vehicles()->first();
     $eventVehicle = $event->vehicles()->first();
     for ($i = 1; $i <= 7; ++$i) {
         $profile = Profile::find($i);
         $attendee = ['email' => $profile->email, 'phone' => $profile->phone, 'first_name' => $profile->first_name, 'middle_name' => $profile->middle_name, 'last_name' => $profile->last_name, 'city' => $profile->city, 'country' => $profile->country, 'birthdate' => $profile->birthdate, 'gender' => $profile->gender, 'accommodation_req' => true, 'accommodation_pref' => 1, 'arrv_ride_req' => true, 'arrv_date' => '2016-04-08', 'arrv_time' => '21:30', 'arrv_airport' => 'DEL', 'arrv_flight' => 'AC2273', 'dept_ride_req' => false, 'status' => 'approved'];
         $profile->conferences()->attach($conference, $attendee);
         $conference->increment('attendee_count');
         $profile->events()->attach($event);
         $profile->rooms()->attach($room);
         $room->increment('guest_count');
         $profile->conferenceVehicles()->attach($conferenceVehicle);
         $conferenceVehicle->increment('passenger_count');
         $profile->eventVehicles()->attach($eventVehicle);
         $eventVehicle->increment('passenger_count');
     }
 }
Beispiel #13
0
 public function addUrl($link)
 {
     $shop_id = null;
     $text = '';
     $profile = new Profile();
     $host = $profile->getHost($link);
     /* @var $shop Profile */
     $shop = Profile::find()->where(['host' => $host])->one();
     if ($shop) {
         $shop_id = $shop->user_id;
         $text .= 'магазин ' . $shop->url . '<br>';
         $text .= 'бонус покупателю ' . $shop->buyer_bonus . '<br>';
         $text .= 'бонус рекомендателю ' . $shop->recommender_bonus . '<br>';
         $text .= 'статус ' . $shop->status->name . '<br>';
     } elseif (!ModerateShop::find()->where(['url' => $host])->exists()) {
         $moderateShop = new ModerateShop(['user_id' => Yii::$app->user->identity->id, 'url' => $host]);
         $moderateShop->save();
     }
     $text .= 'Вы можете давать эту ссылку своим друзьям<br>';
     $url = new Url(['user_id' => Yii::$app->user->identity->id, 'link' => $link, 'shop_id' => $shop_id]);
     $url->save();
     return $text . \yii\helpers\Url::to(['purchase/create', 'affiliate_id' => Yii::$app->user->identity->id, 'url_id' => $url->id], true);
 }
Beispiel #14
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer('app', function ($view) {
         // 是否新生
         if ($is_fresh = Fresh::whereXh(Auth::user()->xh)->exists()) {
             $user = Fresh::find(Auth::user()->xh);
         }
         // 是否在校生
         if ($is_student = Profile::whereXh(Auth::user()->xh)->whereXjzt(config('constants.school.student'))->exists()) {
             $user = Profile::find(Auth::user()->xh);
         }
         // 是否新入校未足一年的学生
         $is_newer = Profile::isFresh(Auth::user())->exists();
         // 是否允许选课
         $allowed_select = Setting::find('XK_KG')->value;
         // 是否允许选通识素质课
         $allowed_general = Setting::find('XK_TS')->value;
         // 是否允许选其他课程
         $allowed_others = Setting::find('XK_QT')->value;
         // 是否允许公体选课
         $allowed_pubsport = Setting::find('XK_GT')->value;
         $view->withIsFresh($is_fresh)->withIsStudent($is_student)->withUser($user)->withIsNewer($is_newer)->withAllowedSelect($allowed_select)->withAllowedGeneral($allowed_general)->withAllowedOthers($allowed_others)->withAllowedPubsport($allowed_pubsport);
     });
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $current_roles = array('3', '2', '1');
     $rules = array('name' => 'required', 'email' => 'required|email');
     $validator = $this->validator($request->all(), $rules);
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     } else {
         $user = User::find($id);
         $user->name = $request->input('name');
         $user->email = $request->input('email');
         $user->profile->bio = $request->input('bio');
         $input = Input::only('role_id');
         $user->removeRole($current_roles);
         $user->assignRole($input);
         $profile = Profile::find($id);
         $profileInputs = Input::only('location', 'bio', 'twitter_username', 'github_username');
         // CHECK IF PROFILE EXISTS THEN CREATE OR SAVE PROFILE
         if ($user->profile == null) {
             $profile = new Profile();
             $profile->fill($profileInputs);
             $user->profile()->save($profile);
         } else {
             $user->profile->fill($profileInputs)->save();
         }
         // SAVE USER CORE SETTINGS
         $user->save();
         return redirect('users/' . $user->id . '/edit')->with('status', 'Successfully updated the user!');
     }
 }
Beispiel #16
0
 /**
  * Retrieve all Event Vehicles a Profile rides in.
  *
  * @param  ProfileRequest  $request
  * @param  int  $pid
  * @return Collection|Response
  */
 public function eventVehicles(ProfileRequest $request, $pid)
 {
     try {
         $profile = Profile::find($pid);
         if (!$profile) {
             return response()->error(404, 'Profile Not Found');
         }
         return $profile->eventVehicles()->get();
     } catch (Exception $e) {
         return response()->error();
     }
 }
Beispiel #17
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use app\models\Profile;
/* @var $this yii\web\View */
/* @var $model app\models\PsychologistTop */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="psychologist-top-form">

    <?php 
$form = ActiveForm::begin();
?>

    <div class="col-md-6">
        <?php 
echo $form->field($model, 'psychologist_id')->dropDownList(ArrayHelper::map(Profile::find()->orderBy('id')->all(), 'user_id', 'lastname'), ['prompt' => 'Выбери психолога'])->label(false);
?>
    </div>
    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Beispiel #18
0
 static function renderAll()
 {
     $url = empty(Profile::find()->where(['user_id' => Yii::$app->user->id])->one()) ? ["/user/update-profile", "id" => Yii::$app->user->id, 'new' => 1] : ["/user/view-profile", "id" => Yii::$app->user->id];
     $menuItems = self::createLiMenu('view-profile', $url, 'Мой профиль', FA::icon('user'));
     $menuItems .= self::createLiMenu("", ['/site/logout'], 'Выйти', FA::icon('sign-out'), true);
     return $menuItems;
 }
 /**
  * Verify request
  * @param $id
  */
 public function actionVerify($id)
 {
     if (!Yii::$app->user->can("admin")) {
         throw new HttpException(403, 'You are not allowed to perform this action.');
     }
     $user = \Yii::$app->user->identity;
     $request = Request::find()->where(['id' => $id])->one();
     $user = User::find()->where(['id' => $request->user_id])->one();
     $profile = Profile::find()->where(['user_id' => $user->id])->one();
     $request_files = RequestFile::find()->where(['request_id' => $request->id])->all();
     $files = [];
     if ($request_files !== NULL) {
         foreach ($request_files as $rf) {
             $file = File::find()->where(['id' => $rf->file_id])->one();
             array_push($files, $file);
         }
     }
     if ($request === NULL) {
         $this->redirect(['site/error']);
     }
     return $this->render('verify', ['request' => $request, 'user' => $user, 'profile' => $profile, 'files' => $files]);
 }
Beispiel #20
0
 /**
  * Delete an existing Profile and its associated Providers
  *
  * @param  string  $profile_id
  * @return mixed
  */
 public function delete($profile_id)
 {
     $profile = Profile::find($profile_id);
     $profile->providers()->delete();
     return $profile->delete();
 }
 public function voteUp(Request $request)
 {
     $poll = Option::with('poll')->find($request->option)->poll;
     $profile = Profile::find(Auth::user()->profile->id);
     if ($poll->profile->contains($profile->id)) {
         return redirect()->back()->withMessage('Your have already voted for this poll')->withStatus('error');
     } else {
         $profile->poll()->attach($poll->id, ['option_id' => $request->option]);
         return redirect()->back()->withMessage('Your Vote has been registered')->withStatus('success');
     }
 }
 /**
  * Delete an Attendee of a Conference.
  *
  * @param  ConferenceAttendeeRequest  $request
  * @param  int  $cid
  * @param  int  $pid
  * @return Response
  */
 public function destroy(ConferenceAttendeeRequest $request, $cid, $pid)
 {
     try {
         $conference = Conference::find($cid);
         if (!$conference) {
             return response()->error(404, 'Conference Not Found');
         }
         $profile = Profile::find($pid);
         if (!$profile) {
             return response()->error(404, 'Profile Not Found');
         }
         $eventVehicles = $conference->eventVehicles()->get();
         foreach ($eventVehicles as $eventVehicle) {
             if ($eventVehicle->passengers()->where('profile_id', $pid)->exists()) {
                 $eventVehicle->passengers()->detach($profile);
                 $eventVehicle->decrement('passenger_count');
             }
         }
         $events = $conference->events()->get();
         foreach ($events as $event) {
             if ($event->attendees()->where('profile_id', $pid)->exists()) {
                 $status = $event->attendees()->where('profile_id', $pid)->first()->pivot->status;
                 $event->attendees()->detach($profile);
                 if ($status == 'approved') {
                     $event->decrement('attendee_count');
                 }
             }
         }
         $conferenceVehicles = $conference->vehicles()->get();
         foreach ($conferenceVehicles as $conferenceVehicle) {
             if ($conferenceVehicle->passengers()->where('profile_id', $pid)->exists()) {
                 $conferenceVehicle->passengers()->detach($profile);
                 $conferenceVehicle->decrement('passenger_count');
             }
         }
         $rooms = $conference->rooms()->get();
         foreach ($rooms as $room) {
             if ($room->guests()->where('profile_id', $pid)->exists()) {
                 $room->guests()->detach($profile);
                 $room->decrement('guest_count');
             }
         }
         $status = $conference->attendees()->where('profile_id', $pid)->first()->pivot->status;
         $conference->attendees()->detach($profile);
         if ($status == 'approved') {
             $conference->decrement('attendee_count');
         }
         $uid = $request->header('ID');
         $this->addActivity($uid, 'cancelled', $cid, 'conference attendance', $pid);
         return response()->success();
     } catch (Exception $e) {
         return response()->error();
     }
 }
 public function actionBloggers()
 {
     /** @var  $allProfiles */
     /** @var \app\models\Profile $profile_id */
     $allProfiles = Profile::find()->select(['user_id', 'nickname'])->all();
     $profileID = array();
     $ownerNickname = array();
     foreach ($allProfiles as $profile_id) {
         $profileID[] = $profile_id->user_id;
         $ownerNickname[] = $profile_id->nickname;
     }
     return $this->render('bloggers', ['profileID' => $profileID, 'ownerNickname' => $ownerNickname]);
 }
Beispiel #24
0
 /**
  * 显示个人资料列表
  * @author FuRongxin
  * @date    2016-01-12
  * @version 2.0
  * @return  \Illuminate\Http\Response 个人资料列表
  */
 public function index()
 {
     $profile = Profile::find(Auth::user()->xh);
     return view('profile.index')->withTitle('个人资料')->withProfile($profile)->withAllowed($this->allowUploadFile());
 }
Beispiel #25
0
 /**
  * Email an Event Attendee about an update to their application.
  *
  * @param  int  $eid
  * @param  int  $pid
  * @param  string  $status
  * @return void
  * @throws Exception
  */
 public function sendEventSignupEmail($eid, $pid, $status)
 {
     try {
         $event = Event::find($eid);
         $eventName = $event->name;
         $profile = Profile::find($pid);
         $user = $profile->user()->first();
         $email = $user->email;
         $name = $profile->first_name;
         if ($email && $user->receive_email && $profile->is_owner) {
             $subject = '[Huddle] Update to Your Event Attendance Request for ' . $eventName;
             $body = 'Hi, ' . $name . '!' . "\n\n" . 'Your request to attend the event ' . $eventName . ' has been ' . $status . '.';
             Mail::queue([], [], function ($message) use($email, $subject, $body) {
                 $message->to($email)->subject($subject)->setBody($body);
             });
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
Beispiel #26
0
 /**
  * 显示学生报名表
  * @author FuRongxin
  * @date    2016-02-22
  * @version 2.0
  * @param   string $kslx 考试类型代码
  * @return  \Illuminate\Http\Response 考试报名表单
  */
 public function edit($kslx)
 {
     if (!Storage::exists(config('constants.file.path.portrait') . Auth::user()->profile->sfzh . '.' . config('constants.file.image.ext'))) {
         return redirect('profile/upfile');
     }
     $exam = Extype::find($kslx);
     $registered = Exregister::whereNd($exam->nd)->whereXh(Auth::user()->xh)->whereKslx($kslx)->exists();
     // 检测是否已经报过CET考试
     if (config('constants.exam.type.cet') == $exam->ksdl) {
         $exams = Exregister::with('type')->whereNd($exam->nd)->whereXh(Auth::user()->xh);
         foreach ($exams as $cet) {
             if (config('constants.exam.type.cet') == $cet->type->ksdl) {
                 abort(403, '已经报名本次' . $cet . '考试,' . $cet . '和' . $exam->ksmc . '不能同时报名');
             }
         }
     }
     $profile = Profile::find(Auth::user()->xh);
     $exam = Extype::find($kslx);
     return view('exam.register')->withTitle('考试报名')->withInfo('请认真核准自己的报名信息')->withProfile($profile)->withExam($exam)->withRegistered($registered);
 }
 /**
  * Delete a Passenger of a Conference Vehicle.
  *
  * @param  Request  $request
  * @param  int  $cid
  * @param  int  $vid
  * @param  int  $pid
  * @return Response
  */
 public function destroy(Request $request, $cid, $vid, $pid)
 {
     try {
         $conference = Conference::find($cid);
         if (!$conference) {
             return response()->error(404, 'Conference Not Found');
         }
         $vehicle = ConferenceVehicle::find($vid);
         if (!$vehicle) {
             return response()->error(404, 'Vehicle Not Found');
         }
         $profile = Profile::find($pid);
         if (!$profile) {
             return response()->error(404, 'Profile Not Found');
         }
         $vehicle->passengers()->detach($profile);
         $vehicle->decrement('passenger_count');
         return response()->success();
     } catch (Exception $e) {
         return response()->error($e);
     }
 }
Beispiel #28
0
 public function actionProfile()
 {
     $model = ($model = Profile::findOne(Yii::$app->user->id)) ? $model : new Profile();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->updateProfile()) {
             $user_name = Yii::$app->user->getIdentity()->username;
             if ($model = Profile::find()->where(['user_id' => Yii::$app->user->id])->one()) {
                 return $this->render('user', ['model' => $model, 'username' => $user_name]);
             }
         } else {
             $this->goHome();
         }
     }
     return $this->render('profile', ['model' => $model]);
 }
Beispiel #29
0
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-index">

    <h1>
        <?php 
echo Html::encode($this->title);
?>
        <?php 
echo Html::a("<span class='glyphicon glyphicon-plus'>", ['create'], ['class' => 'btn btn-success', 'data-toggle' => "tooltip", 'data-placement' => "top", 'title' => "Добавить пользователя"]);
?>
    </h1>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['attribute' => 'username', 'content' => function ($data) {
    if (!empty(\app\models\Profile::find()->where(['user_id' => $data->id])->one())) {
        return Html::a($data->username, ['view-profile', 'id' => $data->id]);
    }
    return $data->username;
}], 'email:email', ['attribute' => 'role', 'content' => function ($data) {
    $role = Yii::$app->authManager->getRolesByUser($data->id);
    $roles = "";
    foreach ($role as $r) {
        $roles .= $r->description . ", ";
    }
    return substr($roles, 0, sizeof($roles) - 3);
}], 'create_at:datetime', 'update_at:datetime', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Beispiel #30
0
?>

    <?php 
echo $form->field($model, 'type_id')->dropDownList(ArrayHelper::map(Type::find()->where(["category" => "user"])->all(), 'id', 'type'));
?>

    <?php 
echo $form->field($model, 'state_id')->dropDownList(ArrayHelper::map(State::find()->where(["category" => "user"])->all(), 'id', 'state'));
?>
    
    <?php 
echo $form->field($model, 'sex')->radioList(['M' => 'Male', 'F' => 'Female']);
?>

    <?php 
echo $form->field($model, 'profile_id')->dropDownList(ArrayHelper::map(Profile::find()->where(["category" => "app"])->all(), 'id', 'name'));
?>

    <?php 
echo $form->field($model, 'authKey')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'accessToken')->textInput(['maxlength' => true]);
?>
    
    <?php 
echo $form->field($model, 'active')->checkbox();
?>
  
	<?php