本文整理汇总了PHP中app\models\Profile::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::find方法的具体用法?PHP Profile::find怎么用?PHP Profile::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Profile
的用法示例。
在下文中一共展示了Profile::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* 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;
}
示例2: actionUpdateProfile
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('/');
}
}
示例3: findModelRegion
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.');
}
}
示例4: acceptAddRequest
/**
* @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');
}
示例5: search
/**
* 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;
}
示例6: search
/**
* 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;
}
示例7: search
/**
* 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;
}
示例8: search
/**
* 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;
}
示例9: search
/**
* 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;
}
示例10: actionUpdate
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;
}
示例11: destroy
/**
* 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);
}
}
示例12: run
/**
* 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');
}
}
示例13: addUrl
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);
}
示例14: boot
/**
* 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);
});
}
示例15: update
/**
* 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!');
}
}