コード例 #1
0
ファイル: PageController.php プロジェクト: yohanes1989/goprop
 public function referralListing(Request $request)
 {
     $rules = ['name' => 'required', 'email' => 'required|email|unique:users,email', 'contact_number' => 'required', 'address' => 'required|min:10', 'province' => 'required', 'city' => 'required', 'subdistrict' => 'required'];
     if ($request->isMethod('POST')) {
         $this->validate($request, $rules);
         $formSubmission = new FormSubmission();
         $formSubmission->fill(['email' => $request->input('email'), 'ip_address' => $request->ip(), 'user_agent' => $request->header('User-Agent')]);
         $formSubmission->saveData([$request->except('_token')]);
         $formSubmission->save();
         $password = str_random(8);
         $user = new User(['email' => $request->input('email'), 'status' => User::STATUS_ACTIVE, 'password' => bcrypt($password)]);
         $user->manage_property = FALSE;
         $user->save();
         $user->assignRole('agent');
         $names = explode(' ', $request->input('name'));
         $profile = new Profile();
         $profile->fill(['first_name' => array_shift($names), 'last_name' => !empty($names) ? implode(' ', $names) : '', 'mobile_phone_number' => $request->input('contact_number'), 'address' => $request->input('address'), 'province' => $request->input('province'), 'city' => $request->input('city'), 'subdistrict' => $request->input('subdistrict')]);
         $profile->user()->associate($user);
         $profile->save();
         $user->load('profile');
         $messageVars = ['name' => $request->input('name'), 'email' => $request->input('email'), 'phone' => $request->input('contact_number'), 'address' => $request->input('address'), 'province' => $request->input('province'), 'city' => $request->input('city'), 'subdistrict' => $request->input('subdistrict')];
         SubscribeHelper::subscribe('referral_agent', $messageVars['email'], $messageVars['name'], null, ['phone' => $messageVars['phone']]);
         Mail::send('frontend.emails.referral_listing', $messageVars, function ($m) {
             $m->from(config('app.contact_from_email'), config('app.contact_from_name'));
             $m->to(config('app.contact_destination'))->subject('Referral Listing Registration');
         });
         $this->notifyReferralAgent($user, $password);
         return redirect()->refresh()->with('messages', [trans('contact.referral_listing_registration_msg')]);
     }
     $validator = JsValidatorFacade::make($rules);
     $content = Page::where('identifier', 'referral-listing')->first();
     return view('frontend.page.referral_listing', ['validator' => $validator, 'content' => $content]);
 }
コード例 #2
0
 public function requestCall(Request $request)
 {
     $rules = ['name' => 'required', 'email' => 'required|email', 'phone' => 'required'];
     $this->validate($request, $rules);
     $messageVars = ['name' => $request->input('name'), 'email' => $request->input('email'), 'phone' => $request->input('phone')];
     SubscribeHelper::subscribe('website_database', $messageVars['email'], $messageVars['name'], null, ['phone' => $messageVars['phone']]);
     Mail::send('frontend.emails.contact', $messageVars, function ($m) {
         $m->from(config('app.contact_from_email'), config('app.contact_from_name'));
         $m->to(config('app.contact_destination'))->subject('Contact Request');
     });
     if ($request->ajax()) {
         return response()->json(['message' => trans('contact.success_message')]);
     }
     return redirect()->back()->with('messages', [trans('contact.success_message')]);
 }