Файловый менеджер - Редактировать - /home/clickysoft/public_html/somni.clickysoft.net/app/Http/Controllers/LandlordRegistrationController.php
Назад
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Repositories\LandlordRepository; use App\Repositories\PaymentRepository; use App\Repositories\SubscriptionRepository; use App\Repositories\TransactionRepository; use App\Interfaces\LandlordRepositoryInterface; use App\Interfaces\PaymentRepositoryInterface; use App\Interfaces\SubscriptionRepositoryInterface; use App\Interfaces\TransactionRepositoryInterface; use App\Http\Requests\Landlord\LandlordRegistrationRequest; use App\Http\Requests\Payment\SubscriptionRequest; use Illuminate\Support\Facades\Auth; use App\Models\Package; use App\Models\User; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rules\Password; use App\Rules\PasswordValidation; use Stripe\Stripe; use Stripe\SetupIntent; class LandlordRegistrationController extends Controller { private LandlordRepositoryInterface $landlordInterfaceObj; //User Interface Object private PaymentRepositoryInterface $paymentInterfaceObj; private SubscriptionRepositoryInterface $subscriptionInterfaceObj; private TransactionRepositoryInterface $transactionInterfaceObj; public function __construct(LandlordRepository $landlordRepo, PaymentRepository $paymentRepo, SubscriptionRepository $subscriptionRepo, TransactionRepository $transactionRepo ) { //Constructor $this->landlordInterfaceObj = $landlordRepo; $this->paymentInterfaceObj = $paymentRepo; $this->subscriptionInterfaceObj = $subscriptionRepo; $this->transactionInterfaceObj = $transactionRepo; } public function index() { return view('landlord.register'); } public function ajaxValidation(Request $request) { $rules = []; $step = $request->input('step', 1); switch ($step) { case 1: $rules = [ 'email' => 'required|email|email:rfc,dns|unique:users', 'password' => ['required', 'confirmed', new PasswordValidation], ]; break; case 2: $rules = [ 'firstname' => 'required', 'lastname' => 'required', 'phone_number' => 'nullable|min:6', ]; $niceNames = ['phone_number' => 'Company Phone']; break; case 3: $rules = [ 'property_name' => 'required', 'address' => 'required', 'company_phone' => 'string|nullable|min:6', 'country' => 'required', 'state' => 'required', 'city' => 'required', 'zip_code' => 'required', 'type' => 'required', ]; $niceNames = [ 'address' => 'Property Address', 'country_id' => 'Country', 'state_id' => 'State', 'city_id' => 'City', 'zip_code' => 'Zip Code' ]; break; case 4: $rules = [ 'no_of_units' => 'required|numeric|max:5', 'lease_term' => 'required', // 'rent_due_date' => 'date|after_or_equal:' . today() . '|required', 'rent_due_date' => 'required', 'monthly_rent' => 'required|regex:/^\d{1,13}(\.\d{1,4})?/|nullable', ]; $niceNames = [ 'no_of_units' => 'Number Of Units', 'lease_term' => 'Lease Term', // 'rent_due_date' => 'date|after_or_equal:' . today() . '|required', 'rent_due_date' => 'Rent Due Date', 'monthly_rent' => 'Monthly Rent', ]; break; case 5: $rules = [ 'unit_size' => 'numeric|nullable', 'amenities' => 'array|nullable', 'security_deposit' => 'required|regex:/^\d{1,13}(\.\d{1,4})?$/|nullable', ]; break; case 6: $rules = [ 'no_of_bedrooms' => 'required', 'no_of_bathrooms' => 'required', 'available_date' => 'nullable|date|after_or_equal:' . today(), ]; $niceNames = [ 'no_of_bedrooms' => 'Number Of Bedrooms', 'no_of_bathrooms' => 'Number Of Bathrooms', 'available_date' => 'Date Available' ]; break; } $validator = Validator::make($request->all(), $rules); if (isset($niceNames)) { $validator->setAttributeNames($niceNames); } if ($validator->fails()) { return response()->json(['errors' => $validator->errors()], 200); } return response()->json(['status' => 'success']); } public function registerLandlord(LandlordRegistrationRequest $request) { try { $landlord = $this->landlordInterfaceObj->createLandlord($request); if ($landlord) { //Login $userCredential = $request->only('email', 'password'); if (Auth::attempt($userCredential)) { $request->session()->regenerate(); return redirect()->route('subcription'); } } } catch (\Throwable $th) { throw $th; } } public function subscribe() { $packages = $this->subscriptionInterfaceObj->getAllPackagesWithInfo(); return view('landlord.plan', compact('packages')); } public function planPayment(Package $package) { $user = auth()->user(); $intent = $user->createSetupIntent(); return view('landlord.payment', compact('package', 'intent')); } public function subscribeUser(SubscriptionRequest $request) { $plan = $this->subscriptionInterfaceObj->getPackageById($request->package_id); $user = auth()->user(); $subscription = $this->subscriptionInterfaceObj->newUserSubscription($plan, $request, $user); if($subscription){ $transaction_id = $this->transactionInterfaceObj->createTransaction( $user->id, null, $plan->price_monthly, 'paid', 'Monthly Subscription Charges', null, json_encode($subscription), null, null, null, 'subscription_charges' ); } return view('landlord.success'); } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка