Exemplo n.º 1
0
 public function showInvoice()
 {
     $user = User::find(Auth::user()->id);
     $invoices = $user->invoices();
     return view('stripe.invoice', compact('invoices'));
 }
Exemplo n.º 2
0
 public static function tidyAddress($address)
 {
     $tidyAddress = '';
     $decodedAddress = User::decodeAddress($address);
     foreach ($decodedAddress as $key => $value) {
         if (!$value) {
             $tidyAddress = rtrim($tidyAddress, self::TIDY_ADDRESS_DEVIDER);
             continue;
         }
         if ($key == 'POSTCODE' || $key == 'STATE') {
             continue;
         }
         $tidyAddress .= $value . ($key == 'TOWN' ? '' : self::TIDY_ADDRESS_DEVIDER);
     }
     return $tidyAddress;
 }
Exemplo n.º 3
0
 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $user = User::whereEmail(config('mail.admin.address'))->first();
     return view('home')->withAdminUser($user);
 }
Exemplo n.º 4
0
 public function create(StoreRequest $request)
 {
     $store_name = $request->input('store_name');
     $address = User::encodeAddress($request->only('mailing-address', 'address_flat_house_floor_building', 'address_colony_street_locality', 'address_landmark', 'address_town_city', 'postcode', 'state'));
     $data = ['name' => $store_name, 'description' => $request->input('description'), 'address' => $address, 'phone_number' => $request->input('code') . $this->delimiter_phone_number . $request->input('phone_number'), 'store_type' => $request->input('business')];
     $validator = $this->validator($data, $this->_rules->toArray());
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator->errors())->withInput();
     }
     $store = Store::create(['name' => $store_name, 'user_id' => Auth::user()->id, 'name_as_url' => strtolower(str_replace('.', '', str_replace(' ', '', $store_name))), 'description' => $data['description'], 'address' => $data['address'], 'phone_number' => $data['phone_number'], 'store_type' => $data['store_type'], 'status' => 'ON_APPROVAL']);
     if (!$store) {
         return redirect()->back()->withErrors(['Failed to create store named (' . $store->name . ')']);
     }
     flash()->success('Store (' . $store->name . ') information will be published when approved by the authority. Please contact Inzaana administrator for further assistance.');
     return redirect()->back();
 }
Exemplo n.º 5
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  User  $user
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, User $user)
 {
     $rules = collect(['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'phone_number' => 'required|numeric|digits:11', 'email_alter' => 'email']);
     $address = User::encodeAddress($request->only('mailing-address', 'address_flat_house_floor_building', 'address_colony_street_locality', 'address_landmark', 'address_town_city', 'postcode', 'state'));
     $inputs = collect(['name' => $request->input('name'), 'email' => $request->input('email'), 'phone_number' => $request->input('phone_number'), 'code' => $request->input('code'), 'address' => $address]);
     if ($request->input('email') == $user->email) {
         $inputs = $inputs->forget('email');
         $rules = $rules->forget('email');
     }
     if ($request->has('password')) {
         if (!Auth::attempt(['email' => $request->get('email'), 'password' => $request->get('oldpass')])) {
             return ['oldpass' => 'Password did not match with existing.'];
         }
         if ($request->input('password') != $request->input('password_confirmation')) {
             return ['password_confirmation' => 'Password did not match with new one.'];
         }
         if (strlen($request->input('password')) < 6) {
             return ['password' => 'Password must have minimum 6 characters'];
         }
         $user->password = bcrypt($request->input('password'));
     }
     $validator = $this->validator($inputs->toArray(), $rules->toArray());
     if ($validator->fails()) {
         return $validator->errors();
     }
     $user->name = $inputs['name'];
     $user->address = $inputs['address'];
     if ($inputs->has('email')) {
         $user->email = $inputs['email'];
     }
     $delimiter_phone_number = '-';
     $user->phone_number = $inputs['code'] . $delimiter_phone_number . $inputs['phone_number'];
     // no errors means empty array
     return [];
 }
Exemplo n.º 6
0
 /**
  * Confirm a customer's email address.
  *
  * @param  string $token
  * @return mixed
  */
 public function confirmEmailCustomer($token)
 {
     $user = User::whereToken($token)->firstOrFail();
     $errors = [];
     if (!$user->confirmEmail()) {
         if ($user->remove()) {
             $errors['AUTH_CONFIRM'] = 'User authentication is not confirmed. Please signup to create your account again. For assistance contact administrator.';
         }
         session()->forget('site');
         session()->forget('store');
         session()->forget('business');
         return redirect()->route('guest::home', ['errors' => collect($errors)]);
     }
     flash('You are now confirmed. Please login.');
     return redirect('/login');
 }