Файловый менеджер - Редактировать - /home/clickysoft/public_html/somni.clickysoft.net/app/Models/Unit.php
Назад
<?php namespace App\Models; use Carbon\Carbon; use DateTimeInterface; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\MediaLibrary\MediaCollections\Models\Media; class Unit extends Model implements HasMedia { use InteractsWithMedia, HasFactory; public $table = 'units'; // protected $appends = [ // 'images', // ]; protected $dates = [ 'rent_due_date', 'available_date', 'created_at', 'updated_at', 'deleted_at', ]; public const LEASE_TERM_SELECT = [ '1_year' => '1 Year', '2_year' => '2 Years', '3_year' => '3 Years', '4_year' => '4 Years', '5_year' => '5 Years', '10_year' => '10 Years', 'quarterly' => 'Quarterly', 'bi_annual' => 'Bi-Annual', ]; public const LAYOUT_TYPE = [ 'studio' => 'Studio', '2_bedroom' => 'Two Bedrooms', '3_bedroom' => 'Three Bedrooms', 'penthouse' => 'Penthouse', ]; protected $fillable = [ 'property_id', 'number', 'slug', 'lease_term', 'rent_due_date', 'monthly_rent', 'security_deposit', 'size', 'description', 'no_of_bedrooms', 'no_of_bathroom', 'layout_type', 'available_date', 'is_complete', 'tenant_user_id', 'is_rent', 'created_at', 'updated_at', 'deleted_at', ]; public function setNumberAttribute($value) { $this->attributes['number'] = $value; $this->attributes['slug'] = str_slug($value); } /** * Get the route key for the model. */ public function getRouteKeyName(): string { return 'slug'; } public function scopeComplete($query) { return $query->where('is_complete', 1); } protected function serializeDate(DateTimeInterface $date) { return $date->format('Y-m-d H:i:s'); } public function registerMediaConversions(Media $media = null): void { $this->addMediaConversion('thumb')->fit('crop', 50, 50); $this->addMediaConversion('preview')->fit('crop', 120, 120); } public function property() { return $this->belongsTo(Property::class, 'property_id'); } public function amenities() { return $this->belongsToMany(Amenity::class); } public function getRentDueDateAttribute($value) { return $value ? Carbon::parse($value)->format(config('panel.date_format')) : null; } public function setRentDueDateAttribute($value) { $this->attributes['rent_due_date'] = $value ? Carbon::createFromFormat(config('panel.date_format'), $value)->format('Y-m-d') : null; } public function getAvailableDateAttribute($value) { return $value ? Carbon::parse($value)->format(config('panel.date_format')) : null; } public function setAvailableDateAttribute($value) { $this->attributes['available_date'] = $value ? Carbon::createFromFormat(config('panel.date_format'), $value)->format('Y-m-d') : null; } public function getImagesAttribute() { $files = $this->getMedia('images'); $files->each(function ($item) { $item->url = $item->getUrl(); $item->thumbnail = $item->getUrl('thumb'); $item->preview = $item->getUrl('preview'); }); return $files; } public function tenantUsers() { return $this->belongsToMany(User::class , 'property_unit_tenant', 'unit_id', 'tenant_user_id'); } public function activeTenantUnitUserLog() { return $this->hasOne(TenantUnitUserLog::class, 'unit_id')->where('status', 'active'); } public function transactionDetail(){ return $this->hasMany(TransactionDetail::class); } // Define the relationship with the Event model public function events() { return $this->hasMany(Event::class); } // Define the relationship with Lease public function leases() { return $this->hasMany(Lease::class); } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка