Файловый менеджер - Редактировать - /home/clickysoft/public_html/somni.clickysoft.net/app/Http/Controllers/LandlordUnitController.php
Назад
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests\Landlord\UpdateUnitRequest; 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\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 Datatables; use App\Models\Event; class LandlordUnitController 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; public function __construct(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; } public function editUnit($id){ $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $verify = $this->userInterfaceObj->checkVerification($user); $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); $unit = $this->landlordInterfaceObj->getUnitsById($id); return view('landlord.unit.edit',compact('user','verify','nCount','notifications','unit')); } public function updateUnit(UpdateUnitRequest $request, $unit_id){ try { //code... $unit_to_update = $request->except(['_token','amenities','date_available','unit_size']); $unit_to_update['available_date'] = $request->date_available; $unit_to_update['size'] = $request->unit_size; $amenities = $request->amenities; $updated = $this->landlordInterfaceObj->updateUnitById($unit_to_update,$amenities,$unit_id); if($updated){ return redirect()->route('landlord.units')->with('success','Unit Updated Successfully'); } } catch (\Throwable $th) { //throw $th; return redirect()->route('landlord.units')->with('error',$th->getMessage()); } } public function deleteUnit($unit_id){ try { $check = $propertyInterfaceObj->checkIfUnitIsDeletable($unit_id); if(!$check){ return back()->with('error','Unit Has Associations, can not delete!'); } $delete = $this->landlordInterfaceObj->deleteUnitById($unit_id); if($delete){ return back()->with('success','Unit Deleted'); } return back()->with('error','Error Deleting Unit'); } catch (\Throwable $th) { return back()->with('error',$th->getMessage()); } } public function ajaxUnit(Request $request){ if($request->ajax()){ $units = ''; $user = $this->landlordInterfaceObj->getLandlordById(auth()->user()->id); $property = $this->landlordInterfaceObj->getSelectedProperty(auth()->user()->id); if($property){ $units = $this->landlordInterfaceObj->getUnitsByPropertyId($property->id); } return Datatables::of($units) ->addIndexColumn() ->addColumn('action',function($row){ $flag = $this->propertyInterfaceObj->checkIfUnitIsDeletable($row->id); if($flag){ $actionBtn = '<div class="yajra-del-edit"><a href="/landlord/delete_unit/'.$row->id.'"><button class="progress-cta alert-yajra">Delete</button></a><a href="/landlord/edit/'.$row->id.'"><button class="progress-cta edit-yajra">Edit</button></a</div>'; }else{ // dd($flag); $actionBtn = '<div class="yajra-del-edit"><a href="/landlord/edit/'.$row->id.'"><button class="progress-cta edit-yajra">Edit</button></a</div>'; } return $actionBtn; }) ->addColumn('invite',function($row){ $inviteBtn = ''; if($row->tenantUsers->isEmpty()){ $inviteBtn = '<button class="editable_hm invite_class" data-bs-toggle="modal" data-bs-target="#sepcialselectModal" data-id="'.$row->id.'" type="button">Invite</button>'; } return $inviteBtn; }) ->addColumn('property_name',function($row){ $property_name = $row->property->name; return $property_name; }) ->addColumn('tenant_name',function($row){ $tenant_name = $row->tenantUsers[0]->name ?? ''; return $tenant_name; }) ->rawColumns(['action','property_name','invite','tenant_name']) ->make(true); } } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка