Файловый менеджер - Редактировать - /home/clickysoft/public_html/somni.clickysoft.net/app/Models/Property.php
Назад
<?php namespace App\Models; use Carbon\Carbon; use DateTimeInterface; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use App\Models\Scopes\PropertyOnlyCompleted; class Property extends Model { use HasFactory; public $table = 'properties'; protected $dates = [ 'purchase_date', 'created_at', 'updated_at', 'deleted_at', ]; protected $fillable = [ 'user_id', 'name', 'slug', 'address', 'type', 'country_id', 'city_id', 'state_id', 'country', 'city', 'state', 'zip_code', 'purchase_date', 'value', 'purchase_term', 'created_at', 'updated_at', 'deleted_at', 'is_selected', 'step_count', 'is_complete', 'format_styles', ]; public const TYPE_SELECT = [ 'single_family_house' => 'Single-Family House', 'cooperative' => 'Cooperative (Co-op)', 'townhome' => 'Townhome', 'duplex' => 'Duplex', 'triplex' => 'Triplex', 'fourplex' => 'Fourplex', 'mobile_home' => 'Mobile Home', 'development' => 'Development', ]; public const PURCHASE_TERM_SELECT = [ 'short_term_rental' => 'Short Term Rental', 'month_to_month_lease' => 'Month To Month Lease', '6_month_lease' => '6 Month Lease', '12_month_lease' => '12 Month Lease', '1_year_lease' => '1 Year Lease', 'multi_year_lease' => 'Multi Year Lease', 'lease_with_purchase_option' => 'Lease With Purchase Option', 'fixed_term_vacation_rental' => 'Fixed Term Vacation Rental', ]; /** * The "booted" method of the model. */ // protected static function booted(): void // { // static::addGlobalScope(new PropertyOnlyCompleted); // } //Local Scope public function scopeComplete($query) { return $query->where('is_complete', 1); } public function setNameAttribute($value) { $this->attributes['name'] = $value; $this->attributes['slug'] = str_slug($value); } protected function serializeDate(DateTimeInterface $date) { return $date->format('Y-m-d H:i:s'); } /** * Get the route key for the model. */ public function getRouteKeyName(): string { return 'slug'; } public function propertyUnits() { return $this->hasMany(Unit::class, 'property_id', 'id'); } public function user() { return $this->belongsTo(User::class, 'user_id'); } public function getPurchaseDateAttribute($value) { return $value ? Carbon::parse($value)->format(config('panel.date_format')) : null; } public function setPurchaseDateAttribute($value) { $this->attributes['purchase_date'] = $value ? Carbon::createFromFormat(config('panel.date_format'), $value)->format('Y-m-d') : null; } public function countryCode() { return $this->belongsTo(Country::class,'country_id'); } public function cityCode() { return $this->belongsTo(City::class,'city_id'); } public function stateCode() { return $this->belongsTo(State::class,'state_id'); } public function tenant_units() { return $this->belongsToMany(Unit::class, 'property_unit_tenant', 'property_id', 'unit_id'); } public function tenants() { return $this->belongsToMany(User::class, 'property_unit_tenant', 'property_id', 'tenant_user_id'); } public function propertyTenant() { return $this->hasMany(PropertyUnitTenant::class, 'property_id', 'id'); } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка