Файловый менеджер - Редактировать - /home/clickysoft/public_html/somni.clickysoft.net/app/Repositories/EventRepository.php
Назад
<?php namespace App\Repositories; use App\Interfaces\EventRepositoryInterface; use App\Repositories\WalletRepository; use App\Models\Property; use App\Models\Unit; use App\Models\User; use App\Models\City; use App\Models\Category; use App\Models\UserInfo; use App\Models\Event; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Str; class EventRepository implements EventRepositoryInterface { public function saveEvent($data){ try { $event = Event::create($data); return [ 'code' => 200, 'message' => $event ]; } catch (\Throwable $th) { // throw $th; return [ 'code' => 500, 'message' => $th->getMessage() ]; } } public function getEventsByTenantId($tenant_id){ $events = Event::with(['event_tenant','event_landlord'])->where('tenant_id',$tenant_id)->where('type','maintenance')->where('is_archive',0)->orderBy('created_at','DESC')->get(); return $events; } public function getEventsByTenantIdForCalender($tenant_id){ $events = Event::with(['event_tenant','event_landlord'])->where('tenant_id',$tenant_id)->where('is_archive',0)->orderBy('created_at','DESC')->get(); return $events; } public function getEventWithTypeMaintenanceByLandlordId($landlord_id){ $events = Event::with(['event_tenant','event_landlord','category','unit'])->where('landlord_id',$landlord_id)->where('type','maintenance')->where('is_archive', 0)->orderBy('created_at','DESC')->get(); return $events; } public function getArchivedEventWithTypeMaintenanceByLandlordId($landlord_id){ $events = Event::with(['event_tenant','event_landlord','category','unit'])->where('landlord_id',$landlord_id)->where('type','maintenance')->where('is_archive', 1)->orderBy('created_at','DESC')->get(); return $events; } public function getEventsByLandlordId($landlord_id){ $events = Event::with(['event_tenant','event_landlord','category','unit'])->where('landlord_id',$landlord_id)->orderBy('created_at','DESC')->get(); return $events; } public function getEventsByLandlordIdLimit($landlord_id){ $events = Event::with(['event_tenant','event_landlord'])->where('landlord_id',$landlord_id)->orderBy('created_at','DESC')->limit(5)->get(); return $events; } public function getEventsByLandlordIdWithPagination($landlord_id){ $events = Event::with(['event_tenant','event_landlord'])->where('landlord_id',$landlord_id)->orderBy('created_at','DESC')->paginate(10); return $events; } public function getEventsByStatus($status){ $events = Event::with(['event_tenant','event_landlord'])->where('status',$status)->orderBy('created_at','DESC')->get(); return $events; } public function getEventsByUnitIdAndTenantID($tenant_id,$unit_id){ $events = Event::with(['event_tenant','event_landlord'])->where('tenant_id',$tenant_id)->where('type','maintenance')->where('is_archive',0)->where('unit_id',$unit_id)->orderBy('created_at','DESC')->get(); return $events; } public function getEventsByUnitIdAndTenantIDForCalender($tenant_id,$unit_id){ $events = Event::with(['event_tenant','event_landlord'])->where('tenant_id',$tenant_id)->where('is_archive',0)->where('unit_id',$unit_id)->orderBy('created_at','DESC')->get(); return $events; } public function getEventByEventId($id){ return Event::with(['event_tenant','event_landlord','event_property','category','unit'])->whereId($id)->first(); } public function updateEvent($data,$event_id){ return Event::whereId($event_id)->update($data); } public function deleteEvent($event_id){ $delete = Event::destroy($event_id); return $delete; } public function updateSingleEventStatus($event_id,$status){ $status_update = Event::whereId($event_id)->update(['status' => $status]); return $status_update; } public function updateSingleEventArchive($event_id,$status){ $status_update = Event::whereId($event_id)->update(['is_archive' => $status]); return $status_update; } public function getLatestMaintenanceActivityByUnitId($unit_id){ return Event::where('unit_id',$unit_id)->where('status','in-progress')->first(); } public function getOverlappingEvents($propertyId, $unitId, $date, $fromTime, $toTime) { return Event::where('property_id', $propertyId) ->where('unit_id', $unitId) ->where('date', $date) ->where(function ($query) use ($fromTime, $toTime) { $query->whereBetween('from_time', [$fromTime, $toTime]) ->orWhereBetween('to_time', [$fromTime, $toTime]) ->orWhere(function ($query) use ($fromTime, $toTime) { $query->where('from_time', '<=', $fromTime) ->where('to_time', '>=', $toTime); }); }) ->get(); } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка