本文整理汇总了PHP中app\models\Profile::user方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::user方法的具体用法?PHP Profile::user怎么用?PHP Profile::user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Profile
的用法示例。
在下文中一共展示了Profile::user方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
}
示例2: 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();
}
}
示例3: 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');
}
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$SYSTEM_ADMINISTRATOR = Sentinel::findRoleByName('System Administrator');
$CONFERENCE_MANAGER = Sentinel::findRoleByName('Conference Manager');
$EVENT_MANAGER = Sentinel::findRoleByName('Event Manager');
$REGULAR_USER = Sentinel::findRoleByName('Regular User');
// ---------------------------------------------------------------------
// USER 1
// ---------------------------------------------------------------------
$user = ['username' => 'admin', 'email' => 'admin@huddle.com', 'password' => 'password1'];
$user = Sentinel::registerAndActivate($user);
$role = $SYSTEM_ADMINISTRATOR;
$role->users()->attach($user);
$user->permissions = $role->permissions;
$user->save();
$profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'System', 'last_name' => 'Administrator', 'city' => 'Vancouver', 'country' => 'Canada', 'gender' => 'male'];
$profile = new Profile($profile);
$profile->user()->associate($user);
$profile->save();
// ---------------------------------------------------------------------
// USER 2
// ---------------------------------------------------------------------
$user = ['username' => 'haniel', 'email' => 'haniel@huddle.com', 'password' => 'password1'];
$user = Sentinel::registerAndActivate($user);
$role = $CONFERENCE_MANAGER;
$role->users()->attach($user);
$user->permissions = $role->permissions;
$user->save();
$profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'Haniel', 'last_name' => 'Martino', 'city' => 'Vancouver', 'country' => 'Canada', 'gender' => 'male'];
$profile = new Profile($profile);
$profile->user()->associate($user);
$profile->save();
// ---------------------------------------------------------------------
// UESR 3
// ---------------------------------------------------------------------
$user = ['username' => 'viggy', 'email' => 'viggy@huddle.com', 'password' => 'password1'];
$user = Sentinel::registerAndActivate($user);
$role = $CONFERENCE_MANAGER;
$role->users()->attach($user);
$user->permissions = $role->permissions;
$user->save();
$profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'Vincent', 'last_name' => 'Lore', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1993-02-08', 'gender' => 'male'];
$profile = new Profile($profile);
$profile->user()->associate($user);
$profile->save();
// ---------------------------------------------------------------------
// USER 4
// ---------------------------------------------------------------------
$user = ['username' => 'gabby', 'email' => 'gabby@huddle.com', 'password' => 'password1'];
$user = Sentinel::registerAndActivate($user);
$role = $CONFERENCE_MANAGER;
$role->users()->attach($user);
$user->permissions = $role->permissions;
$user->save();
$profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'Gabriela', 'last_name' => 'Hernandez', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1993-02-16', 'gender' => 'female'];
$profile = new Profile($profile);
$profile->user()->associate($user);
$profile->save();
// ---------------------------------------------------------------------
// USER 5
// ---------------------------------------------------------------------
$user = ['username' => 'james', 'email' => 'james@huddle.com', 'password' => 'password1'];
$user = Sentinel::registerAndActivate($user);
$role = $CONFERENCE_MANAGER;
$role->users()->attach($user);
$user->permissions = $role->permissions;
$user->save();
$profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'James', 'last_name' => 'Ma', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1992-01-23', 'gender' => 'male'];
$profile = new Profile($profile);
$profile->user()->associate($user);
$profile->save();
// ---------------------------------------------------------------------
// USER 6
// ---------------------------------------------------------------------
$user = ['username' => 'martin', 'email' => 'martin@huddle.com', 'password' => 'password1'];
$user = Sentinel::registerAndActivate($user);
$role = $CONFERENCE_MANAGER;
$role->users()->attach($user);
$user->permissions = $role->permissions;
$user->save();
$profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'Martin', 'last_name' => 'Tsang', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1993-05-15', 'gender' => 'male'];
$profile = new Profile($profile);
$profile->user()->associate($user);
$profile->save();
// ---------------------------------------------------------------------
// USER 7
// ---------------------------------------------------------------------
$user = ['username' => 'chris', 'email' => 'chris@huddle.com', 'password' => 'password1'];
$user = Sentinel::registerAndActivate($user);
$role = $CONFERENCE_MANAGER;
$role->users()->attach($user);
$user->permissions = $role->permissions;
$user->save();
$user->permissions = $role->permissions;
$user->save();
//.........这里部分代码省略.........