Файловый менеджер - Редактировать - /home/c7lekhnath/silverray.com.au/Modules/Property/app/Models/Property.php
Назад
<?php namespace Modules\Property\app\Models; use App\Models\User; use App\Models\Admin; use App\Models\WishList; use Illuminate\Support\Facades\Auth; use Modules\Location\app\Models\City; use Illuminate\Database\Eloquent\Model; use Modules\Property\app\Models\Aminity; use Modules\Property\app\Models\PropertyType; use Modules\Property\app\Models\NearestLocation; use Modules\Property\app\Models\PropertyPurpose; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Factories\HasFactory; use Modules\Property\app\Models\PropertyNearestLocation; use Modules\Property\Database\factories\PropertyFactory; class Property extends Model { use HasFactory; /** * The attributes that are mass assignable. */ protected $fillable = [ 'user_type', 'admin_id', 'user_id', 'property_type_id', 'city_id', 'listing_package_id', 'property_purpose_id', 'slug', 'views', 'phone', 'email', 'website', 'short_description', 'pdf_file', 'thumbnail_image', 'banner_image', 'number_of_unit', 'number_of_room', 'number_of_bedroom', 'number_of_bathroom', 'number_of_floor', 'number_of_kitchen', 'number_of_parking', 'area', 'price', 'period', 'video_link', 'is_featured', 'verified', 'status', 'seo_title', 'seo_description', 'is_popular', 'google_map_embed_code', 'urgent_property', 'top_property', 'expired_date', 'property_search_id', ]; protected static function newFactory(): PropertyFactory { //return PropertyFactory::new(); } public function getTitleAttribute(): ?string { return $this->translation->title; } public function translation(): ?HasOne { return $this->hasOne(PropertyTranslation::class)->where('lang_code', getSessionLanguage()); } public function getTranslation($code): ?PropertyTranslation { return $this->hasOne(PropertyTranslation::class)->where('lang_code', $code)->first(); } public function translations(): ?HasMany { return $this->hasMany(PropertyTranslation::class, 'property_id'); } public function propertyType(){ return $this->belongsTo(PropertyType::class)->with('translation'); } public function propertyPurpose(){ return $this->belongsTo(PropertyPurpose::class)->with('translation'); } public function propertyAminities(){ return $this->hasMany(Aminity::class, 'id'); } public function propertyImages(){ return $this->hasMany(PropertyImage::class); } public function propertyNearestLocations(){ return $this->hasMany(PropertyNearestLocation::class)->with('nearestLocation'); } public function city(){ return $this->belongsTo(City::class); } public function admin(){ return $this->belongsTo(Admin::class); } public function user(){ return $this->belongsTo(User::class); } public function reviews(){ return $this->hasMany(PropertyReview::class); } public function wishlist(): ?HasOne { $user=Auth::guard('web')->user(); if(Auth::guard('web')->check()){ return $this->hasOne(WishList::class, 'property_id')->where(['user_id' => $user->id]); }else{ return $this->hasOne(WishList::class, 'property_id'); } } public function getThumbnailImageUrlAttribute(): ?string { if($this->thumbnail_image){ return asset($this->thumbnail_image); } return asset('backend/img/no-image.png'); } public function getBannerImageUrlAttribute(): ?string { if($this->banner_image){ return asset($this->banner_image); } return asset('backend/img/no-image.png'); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.20 | Генерация страницы: 0.03 |
proxy
|
phpinfo
|
Настройка