Exemplo n.º 1
0
 public function store(UserFormRequest $request)
 {
     $user = new User(['email' => $request->input('email'), 'status' => $request->input('status'), 'password' => bcrypt($request->input('password'))]);
     $user->save();
     $user->assignRole($request->input('role'));
     $profile = new Profile($request->input('profile'));
     $profile->user()->associate($user);
     if ($request->hasFile('profile.profile_picture') && $request->file('profile.profile_picture')->isValid()) {
         $profile->profile_picture = $profile->saveProfilePicture($request->file('profile.profile_picture'));
     }
     $extendedProfile = new ExtendedProfile($request->input('profile.extendedProfile', []));
     $profile->save();
     $profile->extendedProfile()->save($extendedProfile);
     return redirect()->route('admin.user.index')->with('messages', [$user->getName() . ' has been created.']);
 }
Exemplo n.º 2
0
 public function store(UserFormRequest $request)
 {
     $currentUser = Auth::user();
     if (!$currentUser->is('administrator')) {
         return redirect()->back()->withErrors(['You are not authorized to do this.']);
     }
     $user = new User(['email' => $request->input('email'), 'status' => $request->input('status'), 'password' => bcrypt($request->input('password'))]);
     $user->manage_property = $request->input('manage_property', false);
     $user->save();
     $user->assignRole('agent');
     $profile = new Profile($request->input('profile'));
     $profile->user()->associate($user);
     if ($request->hasFile('profile.profile_picture') && $request->file('profile.profile_picture')->isValid()) {
         $profile->profile_picture = $profile->saveProfilePicture($request->file('profile.profile_picture'));
     }
     $profile->save();
     return redirect()->route('admin.agent.index')->with('messages', [$user->getName() . ' has been created.']);
 }
Exemplo n.º 3
0
 public function store(UserFormRequest $request)
 {
     $user = new User(['email' => $request->input('email'), 'status' => $request->input('status'), 'password' => bcrypt($request->input('password'))]);
     $user->save();
     $user->assignRole('authenticated_user');
     $profile = new Profile($request->input('profile'));
     $profile->user()->associate($user);
     if ($request->hasFile('profile.profile_picture') && $request->file('profile.profile_picture')->isValid()) {
         $profile->profile_picture = $profile->saveProfilePicture($request->file('profile.profile_picture'));
     }
     $extendedProfile = new ExtendedProfile($request->input('profile.extendedProfile'));
     $profile->save();
     $profile->extendedProfile()->save($extendedProfile);
     $subscriptions = [];
     foreach ($request->input('subscriptions', []) as $subscriptionSlug) {
         $subscriptions[] = Subscription::findBySlug($subscriptionSlug)->id;
     }
     $user->subscriptions()->sync($subscriptions);
     return redirect()->route('admin.member.index')->with('messages', [$user->getName() . ' has been created.']);
 }
Exemplo n.º 4
0
 protected function create(array $data)
 {
     $user = new User($data);
     $user->password = bcrypt($data['password']);
     $user->save();
     $profile = new Profile($data['profile']);
     $profile->user()->associate($user);
     if (!empty($data['profile']['profile_picture']) && $data['profile']['profile_picture']->isValid()) {
         $profile->profile_picture = $profile->saveProfilePicture($data['profile']['profile_picture']);
     }
     $profile->save();
     $extendedProfile = new ExtendedProfile($data['profile']['extendedProfile']);
     $profile->extendedProfile()->save($extendedProfile);
     if (isset($data['subscriptions'])) {
         $subscriptions = [];
         foreach ($data['subscriptions'] as $subscriptionSlug) {
             $subscriptions[] = Subscription::findBySlug($subscriptionSlug)->id;
         }
         $user->subscriptions()->sync($subscriptions);
     }
     return $user;
 }
Exemplo n.º 5
0
 public function notifySignedUpReferralAgents()
 {
     $submissions = FormSubmission::groupBy('email')->get();
     foreach ($submissions as $submission) {
         if (User::where('email', $submission->email)->count() < 1) {
             $password = str_random(8);
             $user = new User(['email' => $submission->email, 'status' => User::STATUS_ACTIVE, 'password' => bcrypt($password)]);
             $user->manage_property = FALSE;
             $user->save();
             $user->assignRole('agent');
             $names = explode(' ', $submission->getData('name'));
             $profile = new Profile();
             $profile->fill(['first_name' => array_shift($names), 'last_name' => !empty($names) ? implode(' ', $names) : '', 'mobile_phone_number' => $submission->getData('contact_number'), 'address' => $submission->getData('address') . ', ' . $submission->getData('city')]);
             $profile->user()->associate($user);
             $profile->save();
             $user->load('profile');
             $this->notifyReferralAgent($user, $password);
         }
     }
 }