<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;

class Ad extends Model implements HasMedia
{
    use HasFactory, InteractsWithMedia;

    protected $fillable = [
        'status',
        'area_id',
        'service_id',
        'type_id',
        'user_id',
        'marketed_id',
        'price',
        'lat',
        'long',
        'bank',
        'coverage',
        'room',
        'hall',
        'bathroom',
        'car_entrance',
        'driver_room',
        'maid_room',
        'swimming_pool',
        'kitchen',
        'inner_staircase',
        'appendix',
        'furnished',
        'property_age',
        'street_view',
        'determine_area',
        'office_name',
        'office_num',
        'office_reach',
        'des',
        'featured',
        'administration',
        'featured_ad',
        'count_view',
        'interface'
    ];

    const Pending = '0';
    const Active = '1';
    const Expired = '2';
    const FeaturedAd = '1';
    const NotFeaturedAd = '0';

    public function type(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->belongsTo(Type::class);
    }
    public function service(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->belongsTo(Service::class);
    }
    public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->belongsTo(User::class);
    }
    public function area(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->belongsTo(Area::class);
    }

    public function favourite(): \Illuminate\Database\Eloquent\Relations\HasMany
    {
        return $this->hasMany(Favourite::class);
    }
}
