Файловый менеджер - Редактировать - /home/clickysoft/public_html/somni.clickysoft.net/app/Http/Controllers/LandlordController.php
Назад
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Repositories\LandlordRepository; use App\Repositories\UserRepository; use App\Repositories\SubscriptionRepository; use App\Repositories\PropertyRepository; use App\Repositories\TenantRepository; use App\Repositories\NotificationRepository; use App\Repositories\WalletRepository; use App\Repositories\EventRepository; use App\Repositories\TransactionRepository; use App\Repositories\PaymentRepository; use App\Repositories\AdRepository; use App\Repositories\LeaseRepository; use App\Interfaces\LandlordRepositoryInterface; use App\Interfaces\SubscriptionRepositoryInterface; use App\Interfaces\UserRepositoryInterface; use App\Interfaces\PropertyRepositoryInterface; use App\Interfaces\TenantRepositoryInterface; use App\Interfaces\NotificationRepositoryInterface; use App\Interfaces\WalletRepositoryInterface; use App\Interfaces\EventRepositoryInterface; use App\Interfaces\TransactionRepositoryInterface; use App\Interfaces\PaymentRepositoryInterface; use App\Interfaces\AdRepositoryInterface; use App\Interfaces\LeaseRepositoryInterface; use App\Http\Requests\Landlord\UpdateProfileRequest; use App\Http\Requests\Landlord\InviteCodeRequest; use Carbon\Carbon; use App\Events\InvitationSent; use App\Events\NewUnitEvent; use App\Events\ExtraUnitCreated; use App\Events\ExtraUnitPayment; use Datatables; use App\Models\Event; use App\Models\User; use App\Models\Category; use App\Http\Requests\Landlord\NewUnitRequest; use App\Helpers\Helper; use Illuminate\Support\Facades\Storage; class LandlordController extends Controller { private LandlordRepositoryInterface $landlordInterfaceObj; private UserRepositoryInterface $userInterfaceObj; private SubscriptionRepositoryInterface $subscriptionInterfaceObj; private PropertyRepositoryInterface $propertyInterfaceObj; private TenantRepositoryInterface $tenantInterfaceObj; private NotificationRepositoryInterface $notificationInterfaceObj; private WalletRepositoryInterface $walletInterfaceObj; private EventRepositoryInterface $eventInterfaceObj; private TransactionRepositoryInterface $transactionInterfaceObj; private PaymentRepositoryInterface $paymentInterfaceObj; private AdRepositoryInterface $adInterfaceObj; private LeaseRepositoryInterface $leaseInterfaceObj; public function __construct(LeaseRepository $leaseRepo,AdRepository $adRepo,PaymentRepository $paymentRepo ,TransactionRepository $transactionRepo,UserRepository $userRepo,LandlordRepository $landlordRepo, SubscriptionRepository $subscriptionRepo, PropertyRepository $propertyRepo, TenantRepository $tenantRepo, NotificationRepository $notificationRepo,WalletRepository $walletRepo,EventRepository $eventRepo){ $this->landlordInterfaceObj = $landlordRepo; $this->userInterfaceObj = $userRepo; $this->subscriptionInterfaceObj = $subscriptionRepo; $this->propertyInterfaceObj = $propertyRepo; $this->tenantInterfaceObj = $tenantRepo; $this->notificationInterfaceObj = $notificationRepo; $this->walletInterfaceObj = $walletRepo; $this->eventInterfaceObj = $eventRepo; $this->transactionInterfaceObj = $transactionRepo; $this->paymentInterfaceObj = $paymentRepo; $this->paymentInterfaceObj = $paymentRepo; $this->adInterfaceObj = $adRepo; $this->leaseInterfaceObj = $leaseRepo; } public function index(){ $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $property = $this->landlordInterfaceObj->getSelectedProperty(auth()->user()->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); $maintenances = $this->eventInterfaceObj->getEventWithTypeMaintenanceByLandlordId($user->id); $transactions = $this->transactionInterfaceObj->getTransactionForLandlordLimit($user->id); $stats = $this->propertyInterfaceObj->getStats(); $top_property = $this->propertyInterfaceObj->topProperty(); $ads = $this->adInterfaceObj->getLatestBoxAdsLandlord(); if($verify['flag']){ return view('landlord.dashboard',compact('ads','top_property','stats','user','property','maintenances','transactions','nCount','notifications'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.dashboard',compact('ads','top_property','stats','user','property','maintenances','transactions','nCount','notifications')); } public function selectProperty(){ $properties = $this->landlordInterfaceObj->getAllCompletePropertiesWithUnitsCount(auth()->user()->id); $user = auth()->user(); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); return view('landlord.select',compact('properties','user','nCount','notifications')); } public function changeSelectedProperty(Request $request){ $user = auth()->user(); $update = $this->landlordInterfaceObj->changeSelectedPropertyLandlord($user->id,(int)$request->property_id); if($update){ return response()->json([ 'data' => true, 'message' => 'Property Selected' ]); } return response()->json([ 'data' => false, 'message' => 'Error selecting property' ]); } public function addPropertyIndex(){ $user = auth()->user(); $units = ''; $partial_property = $this->landlordInterfaceObj->partialFilledProperty($user->id); $unitCount = $this->propertyInterfaceObj->getUsersActiveUnitsCount($user->id); if($partial_property){ $units = $this->landlordInterfaceObj->getPartialCompletedUnitsByPropertyId($partial_property->id); } if(empty($units) || $units->isEmpty()){ $units = ''; } return view('landlord.add_property',compact('user','partial_property','units','unitCount')); } public function addProperty(Request $request){ // dd($request->all()); $user = auth()->user(); $unitCount = $this->propertyInterfaceObj->getUsersActiveUnitsCount($user->id); $activePlan = $this->subscriptionInterfaceObj->getActivePackageOfUser($user->id); if($request->step_count == 2 || $request->step_count == '2'){ $total_units = $request->number_of_units + $unitCount; // dd($unitCount); if($total_units > $activePlan->units_limit && $activePlan->id == 1){ return response()->json([ 'data' => false, 'message' => 'Unit Limit Reached! Upgrade Plan' ]); } } $response = $this->landlordInterfaceObj->saveSteppedAddPropertyForm($request); if($response['flag']){ if($response['payment']){ $user = auth()->user(); $activePlan = $this->subscriptionInterfaceObj->getActivePackageOfUser($user->id); $per_unit_charges = $activePlan->extra_unit_charges; $data = [ 'unit_count' => $response['new_units_count'], 'property_id' => $response['property_id'], 'per_unit_charges' => $per_unit_charges, 'user' => $user ]; // return redirect()->route('landlord.new.unit.payment.bulk')->with('data',); \Session::put('data',$data); return response()->json([ 'data' => true, 'payment' => true, 'message' => 'Extra Units', 'data' => $data ]); } return response()->json([ 'data' => true, 'message' => 'Property Selected', 'property_id' => $response['property_id'], 'payment' => false, ]); } return response()->json([ 'data' => false, 'message' => 'Server Error!' ]); } public function getPrtialUnitsByPropertyId($property_id){ $response = $this->landlordInterfaceObj->getSpecialPartialCompleteUnitsWithByPropertyId($property_id); return response()->json($response); } public function messageShow(){ $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); if($verify['flag']){ return view('landlord.message',compact('user','nCount','notifications'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.message',compact('user','nCount','notifications')); } public function walletShow(){ $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $property = $this->landlordInterfaceObj->getSelectedProperty(auth()->user()->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); $wallet = $this->walletInterfaceObj->getWalletByUserId($user->id); $transactions = $this->transactionInterfaceObj->getTransactionForLandlordLimit($user->id); $ad = $this->adInterfaceObj->getSingleAddLatestLandlord(); if($verify['flag']){ return view('landlord.wallet',compact('ad','user','property','transactions','nCount','notifications','wallet'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.wallet',compact('ad','user','property','transactions','nCount','notifications','wallet')); } public function unitsShow(){ $units = ''; $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $property = $this->landlordInterfaceObj->getSelectedProperty(auth()->user()->id); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); if($property){ $units = $this->landlordInterfaceObj->getUnitsByPropertyIdLimit($property->id); } $verify = $this->userInterfaceObj->checkVerification($user); if($verify['flag']){ return view('landlord.units',compact('user','property','units','nCount','notifications'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.units',compact('user','property','units','nCount','notifications')); } public function unitsAll(){ $units = ''; $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $property = $this->landlordInterfaceObj->getSelectedProperty(auth()->user()->id); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); if($property){ $units = $this->landlordInterfaceObj->getUnitsByPropertyIdPaginate($property->id); } $verify = $this->userInterfaceObj->checkVerification($user); if($verify['flag']){ return view('landlord.units_all',compact('user','property','nCount','notifications'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.units_all',compact('user','property','nCount','notifications','units')); } public function transactionShowAll(){ $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $property = $this->landlordInterfaceObj->getSelectedProperty(auth()->user()->id); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); $transactions = $this->transactionInterfaceObj->getTransactionForLandlordLimit($user->id); $verify = $this->userInterfaceObj->checkVerification($user); if($verify['flag']){ return view('landlord.transaction_all',compact('user','property','nCount','notifications','transactions'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.transaction_all',compact('user','property','nCount','notifications','transactions')); } public function financeShow(){ $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $property = $this->landlordInterfaceObj->getSelectedProperty(auth()->user()->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); $transactions = $this->transactionInterfaceObj->getTransactionForLandlordLimit($user->id); $stats = $this->propertyInterfaceObj->getStats(); $ad = $this->adInterfaceObj->getSingleAddLatestLandlord(); if($verify['flag']){ return view('landlord.finance',compact('ad','stats','user','property','nCount','notifications','transactions'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.finance',compact('ad','stats','user','property','nCount','notifications','transactions')); } public function maintenanceShow(){ $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $property = $this->landlordInterfaceObj->getSelectedProperty(auth()->user()->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); $maintenances = $this->eventInterfaceObj->getEventWithTypeMaintenanceByLandlordId($user->id); $all_notifications = $this->notificationInterfaceObj->recentNotificationsAll($user->id); $ad = $this->adInterfaceObj->getSingleAddLatestLandlord(); if($verify['flag']){ return view('landlord.maintenance',compact('ad','all_notifications','user','property','nCount','notifications','maintenances'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.maintenance',compact('ad','all_notifications','user','property','nCount','notifications','maintenances')); } public function maintenanceShowAll(){ $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); // $property = $this->landlordInterfaceObj->getSelectedProperty(auth()->user()->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); $maintenances = $this->eventInterfaceObj->getEventsByLandlordIdWithPagination($user->id); if($verify['flag']){ return view('landlord.maintenance_all',compact('user','nCount','notifications','maintenances'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.maintenance_all',compact('user','nCount','notifications','maintenances')); } public function calenderShow(){ $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $property = $this->landlordInterfaceObj->getSelectedProperty(auth()->user()->id); $units = $this->landlordInterfaceObj->getUnitsByPropertyId($property->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); $properties = $this->propertyInterfaceObj->getUsersActiveProperty($user->id); if(count($properties) > 0){ $dd_units = $this->landlordInterfaceObj->getUnitsByPropertyId($properties[0]->id); } if($verify['flag']){ return view('landlord.calender',compact('dd_units','properties','user','units','property','nCount','notifications'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.calender',compact('dd_units','properties','user','units','property','nCount','notifications')); } public function settingShow(){ try { $package_current = null; $exclude_ids = []; $remaining_packages = []; $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); $subscriptions = $user->subscriptions; $intent = $user->createSetupIntent(); if(count($subscriptions) > 0){ $package_current = Helper::getPackageByStripePriceId($subscriptions[0]->stripe_price); array_push($exclude_ids,$package_current->id); $remaining_packages = $this->subscriptionInterfaceObj->getAllActivePackagesExcludingById($exclude_ids); } if($verify['flag']){ return view('landlord.setting',compact('intent','remaining_packages','subscriptions','user','nCount','notifications'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.setting',compact('intent','remaining_packages','subscriptions','user','nCount','notifications')); } catch (\Throwable $th) { return back()->with('error',$th->getMessage()); } } public function inviteCode(InviteCodeRequest $request){ $check_invitation = $this->landlordInterfaceObj->checkInvitation($request->email,$request->unit_id); if($check_invitation){ return back()->with('error','Invitation Already Sent!'); } $created_invitation = $this->landlordInterfaceObj->createInvitationCode($request->email,$request->unit_id); $unit = $this->tenantInterfaceObj->getUnitById($request->unit_id); if(!$created_invitation){ return back()->with('error','Error Generating Code'); } // dd($unit,$created_invitation->invitation_code,auth()->user(),$request->email); //Send Email To Both Parties event(new InvitationSent($unit,$created_invitation->invitation_code,auth()->user(),$request->email)); //Store Notification for Both Parties return back()->with('success','Invitation Code Sent To Recipeint'); } public function mailTest(){ $unit = $this->tenantInterfaceObj->getUnitById(125); \Mail::to("hassanmateen@yopmail.com")->send(new \App\Mail\TenantInvitationEmail($unit, "hdlfausy987a6d98a7sdf87")); } public function ajaxMaintenanceArchive(Request $request){ // foreach(Event::STATUS as $key => $value){ // dd($key); // } if($request->ajax()){ $maintenances = $this->eventInterfaceObj->getArchivedEventWithTypeMaintenanceByLandlordId(auth()->user()->id); return Datatables::of($maintenances) ->addIndexColumn() // ->addColumn('action',function($row){ // $actionBtn = '<a href="/landlord/delete_maintenance/'.$row->id.'"><button class="progress-cta">Delete</button></a>'; // return $actionBtn; // }) ->addColumn('date',function($row){ $first = $row->created_at->format('M. d, Y'); $second = $row->created_at->format(' h:i A'); $date = ' <strong>'.$first.'</strong> '.$second.''; return $date; }) ->addColumn('status',function($row){ $drop_down = '<select onchange=updateFunction(event) class="status_select" id="status_select">'; foreach(Event::STATUS as $key => $value){ if($row->status == $key){ $drop_down .= '<option value="'.$key.'" data-event_id="'.$row->id.'" selected>'.$value.'</option>'; }else{ $drop_down .= '<option value="'.$key.'" data-event_id="'.$row->id.'" >'.$value.'</option>'; } } $drop_down .= '</select>'; return $drop_down; }) ->addColumn('unit_name',function($row){ return $row->unit->number ?? 'N/A'; }) ->addColumn('category',function($row){ return $row->category->name ?? 'N/A'; }) ->rawColumns(['unit_name','category','date','status']) ->make(true); } } public function ajaxMaintenance(Request $request){ // foreach(Event::STATUS as $key => $value){ // dd($key); // } if($request->ajax()){ $maintenances = $this->eventInterfaceObj->getEventWithTypeMaintenanceByLandlordId(auth()->user()->id); return Datatables::of($maintenances) ->addIndexColumn() ->addColumn('action',function($row){ // $actionBtn = '<a href="/landlord/delete_maintenance/'.$row->id.'"><button class="progress-cta">Delete</button></a>'; $actionBtn = '<a href="/archive-events?event_id='.$row->id.'" onclick="return confirm("Are you sure you want to Archive?");"><button class="progress-cta">Archive</button></a>'; return $actionBtn; }) ->addColumn('date',function($row){ $first = $row->created_at->format('M. d, Y'); $second = $row->created_at->format(' h:i A'); $date = ' <strong>'.$first.'</strong> '.$second.''; return $date; }) ->addColumn('status',function($row){ $drop_down = '<select onchange=updateFunction(event) class="status_select" id="status_select">'; foreach(Event::STATUS as $key => $value){ if($row->status == $key){ $drop_down .= '<option value="'.$key.'" data-event_id="'.$row->id.'" selected>'.$value.'</option>'; }else{ $drop_down .= '<option value="'.$key.'" data-event_id="'.$row->id.'" >'.$value.'</option>'; } } $drop_down .= '</select>'; return $drop_down; }) ->addColumn('unit_name',function($row){ return $row->unit->number ?? 'N/A'; }) ->addColumn('category',function($row){ return $row->category->name ?? 'N/A'; }) ->rawColumns(['action','unit_name','category','date','status']) ->make(true); } } public function deleteMaintenance($event_id){ $delete = $this->eventInterfaceObj->deleteEvent($event_id); if($delete){ return back()->with('success','Event Deleted'); } return back()->with('error','Event Deleted'); } public function updateEventStatus(Request $request){ $update = $this->eventInterfaceObj->updateSingleEventStatus($request->event_id,$request->status); if($update){ return response()->json([ 'code' => 200, 'message' => 'Status Updated', ],200); } return response()->json([ 'code' => 500, 'message' => 'Error Updating', ],500); } public function ajaxTransaction(Request $request){ if($request->ajax()){ $transactions = $this->transactionInterfaceObj->getTransactionForLandlord(auth()->user()->id); return Datatables::of($transactions) ->addIndexColumn() ->addColumn('action',function($row){ $actionBtn = '<button type="button" class="download-cta dashed-cta generate_pdf_btn" data-transaction_id="'.$row->id.'">Download</button>'; return $actionBtn; }) ->addColumn('date',function($row){ $first = $row->created_at->format('M. d, Y'); $second = $row->created_at->format(' h:i A'); $date = ' <strong>'.$first.'</strong> '.$second.''; return $date; }) ->addColumn('unit_no',function($row){ $unitNumber = $row->transactionDetails[0]->unit->number ?? 'N/A'; return $unitNumber; }) ->addColumn('payee_name',function($row){ $payeeName = $row->payee->name ?? 'N/A'; return $payeeName; }) ->addColumn('invoice_number',function($row){ $invoiceNumber = 'Invoice-'; $invoiceNumber .= $row->id ?? 'N/A'; return $invoiceNumber; }) ->addColumn('amount',function($row){ $amount = number_format((double) str_replace(',', '', $row->amount), 2); return $amount; }) ->addColumn('status',function($row){ if($row->status == 'paid'){ $status = '<span class="status-completed part-paid">'.$row->status.'</span>'; }else{ $status = '<span class="status-completed">'.$row->status.'</span>'; } return $status; }) ->rawColumns(['action','unit_no','date','payee_name','invoice_number','status','amount']) ->make(true); } } public function unitCreateShow(){ $disabled_flag = 0; // Can create $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $intent = $user->createSetupIntent(); $property = $this->landlordInterfaceObj->getSelectedProperty(auth()->user()->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); $units = $this->propertyInterfaceObj->getTotalUnitsCount($user); $package = $this->subscriptionInterfaceObj->getActivePackageOfUser($user->id); if($package->id == config('constants.subscriptions.free') && $units >= config('constants.subscriptions.unit_limit') ){ $disabled_flag = 1; // Can not create } if($package->id != config('constants.subscriptions.free') && $units >= config('constants.subscriptions.unit_limit') ){ $disabled_flag = 2; // has to pay } if($verify['flag']){ return view('landlord.unit.unit_create',compact('user','property','nCount','notifications','disabled_flag','package','intent'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.unit.unit_create',compact('user','property','nCount','notifications','disabled_flag','package','intent')); } public function saveUnit(NewUnitRequest $request){ // dd($request->all()); try { $user = auth()->user(); // $property = $this->landlordInterfaceObj->getSelectedProperty(auth()->user()->id); // $units = $this->propertyInterfaceObj->getTotalUnitsCount($user); // $package = $this->subscriptionInterfaceObj->getActivePackageOfUser($user->id); $new_unit = $this->propertyInterfaceObj->createUnit($request,$request->flag); event(new NewUnitEvent($new_unit,$user)); if($new_unit){ return redirect()->route('landlord.units')->with('success','New Unit ('.$new_unit->number.') created'); } return back()->with('error', 'Error Occured'); } catch (\Throwable $th) { return back()->with('error',$th->getMessage()); } } public function unitPaymentBulkIndex(Request $request){ try { $data = \Session::get('data'); $user = auth()->user(); $intent = $user->createSetupIntent(); $activePlan = $this->subscriptionInterfaceObj->getActivePackageOfUser($user->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); // dd($data); $total_units = $data['unit_count'] ?? []; $extra_to_charge_for = abs($total_units - $activePlan->units_limit); $per_unit_charges = $activePlan->extra_unit_charges; $total_amount = $extra_to_charge_for * $per_unit_charges; $property_id = $data['property_id'] ?? 0; $paymentMethods = $user->paymentMethods(); return view('landlord.bulk_unit_payment', compact('paymentMethods','intent','user','nCount','notifications','total_amount','per_unit_charges','total_units','property_id','extra_to_charge_for')); } catch (\Throwable $th) { return back()->with('error',$th->getMessage()); } } public function paymentCaptureExtraUnit(Request $request){ try { $paymentMethodId = (isset($request->save_card)) ? $request->save_card : $request->paymentMethodId; $user = auth()->user(); $property = $this->propertyInterfaceObj->getPropertyById($request->property_id); $payload = $this->paymentInterfaceObj->extraUnitPayment($user,$paymentMethodId,$request->amount_to_pay,$request->transaction_charges); if($payload['code'] == 200){ //UpdateProperty and its units to complete $property->update(['is_complete' => 1]); foreach($property->propertyUnits as $unit){ $unit->update(['is_complete' => 1]); } //Notification event(new ExtraUnitCreated($property, $user)); event(new ExtraUnitPayment($property,$user,$request->amount_to_pay,$request->extra_to_charge_for)); \Session::forget('data'); return redirect()->route('landlord.dashboard')->with('success','Payment Made, Property Created'); } } catch (\Throwable $th) { return back()->with('error', $th->getMessage()); } } public function getSingleEvent($id){ try { $user = auth()->user(); $dd_units = []; $event = $this->eventInterfaceObj->getEventByEventId($id); // dd($event ); $properties = $this->propertyInterfaceObj->getUsersActiveProperty($user->id); if(count($properties) > 0){ $dd_units = $this->landlordInterfaceObj->getUnitsByPropertyId($properties[0]->id); } $categories = Category::all(); if($event){ // Assuming $event is an instance of your Event model or a stdClass object $eventDate = Carbon::parse($event->date); $today = Carbon::now(); if ($eventDate->lte($today)) { // Event date is before or equal to today return response()->json( [ 'code' => 400, 'message' => 'Event Uneditable', 'event' => $event, 'properties' => $properties, 'units' => $dd_units, 'categories' => $categories ], 200 ); } return response()->json( [ 'code' => 200, 'message' => 'Event Found', 'event' => $event, 'properties' => $properties, 'units' => $dd_units, 'categories' => $categories ], 200 ); }else{ return response()->json( [ 'code' => 404, 'message' => 'Event Not Found' ], 404 ); } } catch (\Throwable $th) { return response()->json( [ 'code' => 500, 'message' => $th->getMessage() ], 500 ); } } public function getUnitsAjax($id){ try { $units = $this->propertyInterfaceObj->getUnitsByPropertyId($id); return response()->json( [ 'code' => 200, 'message' => 'Units Found', 'units' => $units ], 200 ); } catch (\Throwable $th) { return response()->json( [ 'code' => 500, 'message' => $th->getMessage() ], 500 ); } } public function LeaseIndex(Request $request){ $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $property = $this->landlordInterfaceObj->getSelectedProperty(auth()->user()->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); $maintenances = $this->eventInterfaceObj->getEventWithTypeMaintenanceByLandlordId($user->id); $transactions = $this->transactionInterfaceObj->getTransactionForLandlordLimit($user->id); $stats = $this->propertyInterfaceObj->getStats(); $top_property = $this->propertyInterfaceObj->topProperty(); $ads = $this->adInterfaceObj->getLatestBoxAdsLandlord(); $leases = $this->leaseInterfaceObj->getAllLeases($request->all(), auth()->user()->id); if($verify['flag']){ return view('landlord.lease',compact('leases','ads','top_property','stats','user','property','maintenances','transactions','nCount','notifications'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.lease',compact('leases','ads','top_property','stats','user','property','maintenances','transactions','nCount','notifications')); } public function sendLeaseFileUpload(Request $request){ $request->validate([ 'file' => 'required|mimes:pdf|max:3240', // Example: Allow only PDF files up to 3 MB ], [ 'file.required' => 'Please upload a PDF file.', 'file.mimes' => 'The uploaded file must be in PDF format.', 'file.max' => 'The PDF file size must not exceed 3 MB.', ]); // Get the user ID from the request $user = auth()->user(); $document = $this->leaseInterfaceObj->leaseDocumentUpload($request->file,$user, null); if($document){ return $document; } return false; } public function detailPageIndex(Request $request){ // dd($request->all()); $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); $properties = $this->propertyInterfaceObj->getUsersActiveProperty($user->id); if(count($properties) > 0){ $dd_units = $this->landlordInterfaceObj->getUnitsByPropertyId($properties[0]->id); } $document_id = $request->doc_id; $document = $this->leaseInterfaceObj->getDocById($document_id); if($verify['flag']){ return view('landlord.lease_single',compact('dd_units','properties','document','user','nCount','notifications'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.lease_single',compact('dd_units','properties','document','user','nCount','notifications')); } public function leaseListIndex(){ $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); $templates = $this->leaseInterfaceObj->getTemplatesByType('general'); $templates_mine = $this->leaseInterfaceObj->getTemplatesByUserIdAndType($user->id,'user'); if($verify['flag']){ return view('landlord.lease_select',compact('templates_mine','templates','user','nCount','notifications'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.lease_select',compact('templates_mine','templates','user','nCount','notifications')); } public function sendLeaseIndex(Request $request){ // return response()->json([ // 'success' => 200, // 'message' => 'Lease Sent!', // 'doc_id' => $request->doc_id, // ],200); $store = $this->leaseInterfaceObj->sendLeaseForSigning($request->doc_id,$request->email, $request->doc_name ?? null); // dd('inside sendLeaseIndex',$store); $flag = $store['flag']; switch ($flag) { case 0: return response()->json([ 'error' => 404, 'message' => $store['message'], ],404); break; case 1: return response()->json([ 'error' => 404, 'message' => $store['message'], ],404); break; case 2: return response()->json([ 'success' => 200, 'message' => $store['message'], // 'Lease Sent!' 'lease_id' => $store['lease']->id, ],200); break; case 3: return response()->json([ 'success' => 301, 'message' => $store['message'], 'url' => $store['url'], ],200); break; } } public function leaseSentIndex(Request $request){ $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); $lease = $this->leaseInterfaceObj->getLeaseById($request->lease_id); if($verify['flag']){ return view('landlord.lease_detail',compact('lease','user','nCount','notifications'))->with('verification','Please verify your account. It will be deactivated in '.$verify['days'].' days. <a href="javascript:void(0)" onclick="sendEmailVerification()">Send Verification Email</a>'); } return view('landlord.lease_detail',compact('lease','user','nCount','notifications')); } public function deleteLeaseIds(Request $request){ try { $lease_id = $request->lease_ids; $delete = $this->leaseInterfaceObj->deleteLeases($lease_id); if($delete){ return response()->json([ 'success' => 200, 'message' => 'Deleted!', ],200); } return response()->json([ 'success' => 400, 'message' => $delete, ],400); } catch (\Throwable $th) { //throw $th; return response()->json([ 'error' => 500, 'message' => $th->getMessage().'On line => '.$th->getLine(), ],500); } } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка