当前位置: 首页>>代码示例>>PHP>>正文


PHP Profile::save方法代码示例

本文整理汇总了PHP中app\models\Profile::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::save方法的具体用法?PHP Profile::save怎么用?PHP Profile::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Profile的用法示例。


在下文中一共展示了Profile::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 /**
  * Creates a new Profile model.
  * For ajax request will return json object
  * and for non-ajax request if creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $request = Yii::$app->request;
     $model = new Profile();
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($request->isGet) {
             return ['title' => "Create new Profile", 'content' => $this->renderPartial('create', ['model' => $model]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
         } else {
             if ($model->load($request->post()) && $model->save()) {
                 return ['forceReload' => 'true', 'title' => "Create new Profile", 'content' => '<span class="text-success">Create Profile success</span>', 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::a('Create More', ['create'], ['class' => 'btn btn-primary', 'role' => 'modal-remote'])];
             } else {
                 return ['title' => "Create new Profile", 'content' => $this->renderPartial('create', ['model' => $model]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
             }
         }
     } else {
         /*
          *   Process for non-ajax request
          */
         if ($model->load($request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     }
 }
开发者ID:alfredosotil,项目名称:swinnapp,代码行数:35,代码来源:ProfileController.php

示例2: 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();
 }
开发者ID:lyovkin,项目名称:elcoinbank,代码行数:13,代码来源:ProfileService.php

示例3: 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(); */
 }
开发者ID:efabrikov,项目名称:chomu,代码行数:35,代码来源:Profile.php

示例4: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $modelUser = new User();
     $modelProfile = new Profile();
     $roles = AuthItem::find()->all();
     $arrayRoles = ArrayHelper::map($roles, 'name', 'description');
     $regions = Region::find()->all();
     $arrayRegions = ArrayHelper::map($regions, 'id', 'name');
     if ($modelUser->load(Yii::$app->request->post())) {
         if ($modelUser->validate()) {
             $modelUser->setPassword($modelUser->password_hash);
             if ($modelUser->save(false)) {
                 $modelProfile->user_id = $modelUser->id;
                 $modelProfile->worker_name = $modelUser->worker_name;
                 $modelProfile->telephone = $modelUser->telephone;
                 $modelProfile->head_position = $modelUser->head_position;
                 $modelProfile->head_name = $modelUser->head_name;
                 $modelProfile->region_id = $modelUser->region;
                 if ($modelProfile->save(false)) {
                     $auth = Yii::$app->authManager;
                     $auth->revokeAll($modelUser->id);
                     $access = $auth->getRole($modelUser->access);
                     if ($auth->assign($access, $modelUser->id)) {
                         return $this->redirect(['view', 'id' => $modelUser->id]);
                     }
                 }
             }
         }
     }
     return $this->render('create', ['model' => $modelUser, 'arrayRoles' => $arrayRoles, 'arrayRegions' => $arrayRegions]);
 }
开发者ID:filimonchuk93,项目名称:monitoring.my,代码行数:36,代码来源:UserController.php

示例5: create

 /**
  * Create a new Profile
  *
  * @param  \App\User  $user
  * @param  string  $name
  * @return \App\Models\Profile
  */
 public function create($user, $name)
 {
     $profile = new Profile();
     $profile->name = $name;
     $profile->user_id = $user->id;
     $profile->save();
     return $profile;
 }
开发者ID:remusb,项目名称:gemini-web,代码行数:15,代码来源:ProfileRepository.php

示例6: 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();
     }
 }
开发者ID:phstoned,项目名称:blog-boostrap,代码行数:8,代码来源:ProfileController.php

示例7: actionCreate

 /**
  * Creates a new Profile model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Profile();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'user_id' => $model->user_id, 'state_id' => $model->state_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:hscstudio,项目名称:psiaga,代码行数:14,代码来源:ProfileController.php

示例8: 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');
 }
开发者ID:christopherstock,项目名称:laravel-workshop1,代码行数:11,代码来源:Profile.php

示例9: actionView

 public function actionView()
 {
     $model = Profile::find()->where('user_id = ' . Yii::$app->user->id)->one();
     if (!$model) {
         $modelProfile = new Profile();
         $modelProfile->user_id = Yii::$app->user->id;
         $modelProfile->save(false);
     } else {
         $modelProfile = $model;
     }
     return $modelProfile;
 }
开发者ID:defektrain,项目名称:sgm-rest,代码行数:12,代码来源:ProfileController.php

示例10: 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'));
     }
 }
开发者ID:juliardi,项目名称:jualjasa,代码行数:12,代码来源:ProfileController.php

示例11: 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);
 }
开发者ID:CatherineCD,项目名称:project,代码行数:12,代码来源:User.php

示例12: store

 /**
  * Create a Profile for a User.
  *
  * @param  ProfileRequest  $request
  * @param  int  $uid
  * @return Response
  */
 public function store(ProfileRequest $request, $uid)
 {
     try {
         $user = User::find($uid);
         if (!$user) {
             return response()->error(404, 'User Not Found');
         }
         $profile = new Profile($request->all());
         $profile->user()->associate($user);
         $profile->save();
         return response()->success();
     } catch (Exception $e) {
         return response()->error();
     }
 }
开发者ID:vinlore,项目名称:huddle,代码行数:22,代码来源:ProfileController.php

示例13: 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;
 }
开发者ID:akoch-ov,项目名称:skidos,代码行数:16,代码来源:UserController.php

示例14: signup

 /**
  * Register a new Regular User and create its owner Profile.
  *
  * @param  RegisterUserRequest  $request
  * @return Response
  */
 function signup(RegisterUserRequest $request)
 {
     try {
         $user = ['username' => $request->username, 'email' => $request->email, 'password' => $request->password];
         $user = Sentinel::registerAndActivate($user);
         $role = Sentinel::findRoleByName('Regular User');
         $role->users()->attach($user);
         $user->permissions = $role->permissions;
         $user->save();
         $profile = ['is_owner' => true, 'email' => $request->email, 'phone' => $request->phone, 'first_name' => $request->first_name, 'middle_name' => $request->middle_name, 'last_name' => $request->last_name, 'city' => $request->city, 'country' => $request->country, 'birthdate' => $request->birthdate, 'gender' => $request->gender];
         $profile = new Profile($profile);
         $profile->user()->associate($user);
         $profile->save();
         Log::info('[User] ' . $request->ip() . ' registered User ' . $user->getKey());
         return $this->signin($request);
     } catch (Exception $e) {
         return response()->error();
     }
 }
开发者ID:vinlore,项目名称:huddle,代码行数:25,代码来源:AuthController.php

示例15: 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');
     }
 }
开发者ID:vinlore,项目名称:huddle,代码行数:45,代码来源:AttendeesSeeder.php


注:本文中的app\models\Profile::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。