本文整理汇总了PHP中app\models\Profile类的典型用法代码示例。如果您正苦于以下问题:PHP Profile类的具体用法?PHP Profile怎么用?PHP Profile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Profile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createProfile
/**
* Create user profile
*
* @param Request $data
* @param type $id int
*/
public static function createProfile($data, $id)
{
$profile = new Profile();
$profile->user_id = $id;
$profile->about = "Моя информация";
$profile->save();
}
示例2: socialSave
public static function socialSave($user, $info)
{
$prof = new Profile();
$prof->user_id = $user->id;
$prof->name = $info['name'];
//common
if (!empty($info['first_name'])) {
$prof->name = $info['first_name'];
}
if (!empty($info['last_name'])) {
$prof->last_name = $info['last_name'];
}
//vk
if (!empty($info['photo_rec'])) {
$prof->thumb_photo = $info['photo_rec'];
}
if (!empty($info['photo_medium'])) {
$prof->thumb_photo = $info['photo_medium'];
}
if (!empty($info['photo_big'])) {
$prof->photo = $info['photo_big'];
}
//fb
if (!empty($info['picture'])) {
$prof->thumb_photo = $info['picture']['data']['url'];
}
//set default
if (!$prof->thumb_photo) {
$prof->thumb_photo = '/web/images/profile_thumb_photo_default.png';
}
$prof->save(false);
/* echo '<pre>';
print_r($info);
die(); */
}
示例3: actionInit
public function actionInit()
{
//roles
//user admin psychologist school
$auth = Yii::$app->authManager;
//$user = $auth->createRole('user');
$adminUser = new User();
$adminUser->email = 'admin@gmail.com';
$adminUser->setPassword('123456');
$adminUser->generateAuthKey();
$adminUser->save();
$admin = $auth->createRole('admin');
$auth->add($admin);
$averageUser = new User();
$averageUser->email = 'user@gmail.com';
$averageUser->setPassword('123456');
$averageUser->generateAuthKey();
$averageUser->save();
$profile = new Profile();
$model = new SignupForm();
$model->first_name = "Юзер";
$model->last_name = "Юзерович";
$model->second_name = "Юзеров";
$profile->initProfile($model, $averageUser->id);
$user = $auth->createRole('user');
$auth->add($user);
/* $accessAdmin = $auth->createPermission('accessAdmin');
$accessAdmin->description = 'Access admin';
$auth->add($accessAdmin);
$auth->addChild($admin, $accessAdmin);*/
//$psychologist = $auth->createRole('psychologist');
/*// add "createPost" permission
$createPost = $auth->createPermission('createPost');
$createPost->description = 'Create a post';
$auth->add($createPost);
// add "updatePost" permission
$updatePost = $auth->createPermission('updatePost');
$updatePost->description = 'Update post';
$auth->add($updatePost);
// add "author" role and give this role the "createPost" permission
$author = $auth->createRole('author');
$auth->add($author);
$auth->addChild($author, $createPost);
// add "admin" role and give this role the "updatePost" permission
// as well as the permissions of the "author" role
$admin = $auth->createRole('admin');
$auth->add($admin);
$auth->addChild($admin, $updatePost);
$auth->addChild($admin, $author);
// Assign roles to users. 1 and 2 are IDs returned by IdentityInterface::getId()
// usually implemented in your User model.
$auth->assign($author, 2);*/
$auth->assign($admin, 1);
$auth->assign($user, 2);
}
示例4: actionLoadProfiles
public function actionLoadProfiles()
{
$profileData = [['user_id' => '14', 'birthday' => '1942-02-02', 'nickname' => 'testing', 'background_img' => 'forback.png', 'avatar' => 'forback.png'], ['user_id' => '15', 'birthday' => '1998-02-02', 'nickname' => 'testing2', 'background_img' => 'forback.png', 'avatar' => 'forback.png']];
foreach ($profileData as $data) {
$profile = new Profile($data);
$profile->save();
}
}
示例5: store
public function store(Request $request)
{
$this->validate($request, ['name' => 'required|min:1']);
$profile = new ProfileModel();
$profile->name = $request->input('name');
$profile->surname = $request->input('surname');
$profile->phone = $request->input('phone');
$profile->email = $request->input('email');
$profile->save();
return redirect()->action('UsersController@index');
}
示例6: facebookCallback
public function facebookCallback()
{
try {
$state = $this->security->getToken();
$code = $this->request->getQuery('code');
$error = $this->request->getQuery('error');
$callback = $this->request->getQuery('callback');
if (!empty($error)) {
if ($error === 'access_denied') {
throw new FbCallbackException('FB authorization error: ' . $error);
} else {
throw new FbCallbackException('FB authorization error: ' . $error);
}
}
if (empty($code)) {
throw new FbCallbackException('Ups, something went wrong during authorization');
}
$facebook_response = $this->facebook->getAccessToken($code, $state, $callback);
$access_token = $facebook_response->access_token;
$uid = $this->facebook->getUid($access_token);
$profile = Profile::findFirst(['uid = ?0', 'bind' => [$uid]]);
if (empty($profile)) {
// No user, let's register it
// TODO: encrypt access_token
// TODO: Change default facebook avatar by ours
// TODO: if user doesn't provide us with email we can't register it
// TODO: facebook date format can vary
$me = $this->facebook->me($access_token);
// Create user
$user = new User();
$user = $user->assignFromFacebook($me);
if ($user->save()) {
// Create profile and assign to the user
$profile = new Profile();
$profile->createFromFacebook($me->id, $access_token, $user->id);
return new Response(json_encode($user));
} else {
throw new InvalidFbUser($user);
}
} else {
// User already registered, update access_token
$profile->save(['access_token' => $access_token]);
$user = $profile->getUser();
return new Response(json_encode($user->toArray()));
}
} catch (FbCallbackException $e) {
return $e->returnResponse();
} catch (InvalidFbUser $e) {
return $e->returnResponse();
} catch (\Exception $e) {
return new Response($e->getMessage(), 409);
}
}
示例7: postCreate
public function postCreate()
{
$postValue = $this->getProfileInput();
$profile = new Profile();
if ($profile->validate($postValue)) {
$profile->fill($postValue);
$profile->save();
return redirect(route('home'));
} else {
return view('profile.create', compact('profile'));
}
}
示例8: findOrCreateUser
public static function findOrCreateUser($vk_id)
{
if (!User::findByVkId($vk_id)) {
$model = new User();
$model->vk_id = $vk_id;
$model->save();
$profile = new Profile();
$profile->user_id = $model->id;
$profile->save();
}
return User::findByVkId($vk_id);
}
示例9: actionRegister
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]);
}
示例10: actionRegister
public function actionRegister()
{
$model = new User();
$profile = new Profile();
if ($model->load(Yii::$app->request->getBodyParams(), '') && $model->validate()) {
if ($model->validate()) {
$id = $model->register();
$profile->createProfile($id);
return ['success' => true];
}
} else {
return $model;
}
}
示例11: actionSignup
public function actionSignup()
{
$model = new SignupForm();
if ($model->load(Yii::$app->request->post())) {
if ($user = $model->signup()) {
$profile = new Profile();
if ($profile->initProfile($model, $user->id)) {
if (Yii::$app->getUser()->login($user)) {
return $this->goHome();
}
}
}
}
return $this->render('signup', ['model' => $model]);
}
示例12: createShop
private function createShop($login, $buyer_bonus, $recommender_bonus)
{
$user = new User();
$user->email = $login;
$user->setPassword($user->email);
$user->generateAuthKey();
$user->save(false);
$profile = new Profile();
$profile->user_id = $user->id;
$profile->url = 'https://temp-mail.ru';
$profile->buyer_bonus = $buyer_bonus;
$profile->recommender_bonus = $recommender_bonus;
$profile->save(false);
$this->auth->assign($this->auth->createRole(User::ROLE_SHOP), $user->id);
return $user;
}
示例13: 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;
}
示例14: actionView
public function actionView($title)
{
$eventId = explode('-', $title)[1];
//$training = Events::find(['id' => $eventId[1]])->one();
$training = $this->findModel($eventId);
return $this->render('training', ['training' => $training, 'organizer' => Profile::findOne(['user_id' => $training['organizer_id']]), 'eventsList' => Events::find()->limit('4')->all()]);
}
示例15: actionIndex
public function actionIndex()
{
if (!Yii::$app->user->identity) {
return $this->goHome();
}
$profile = new Profile();
$this->_profile = $profile->getProfile();
/*if(Yii::$app->user->identity->status == User::STATUS_WAIT){
return $this->goHome();
} else*/
if (Yii::$app->user->identity->status == User::STATUS_BLOCKED) {
return $this->goHome();
}
\Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => '']);
return $this->render('index', ['model' => $this->findModel(), '_profile' => $this->_profile]);
}