<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * @package App\Models
 * @property int $id
 * @property int $service_id
 * @property int|null $power_id
 * @property int $city_id
 * @property int $user_id
 * @property int|null $problem_id
 * @property string|null $comment
 * @property int $phone
 * @property string $full_name
 * @property string $status // pending, accepted, closed
 * @property \Illuminate\Support\Carbon $created_at
 * @property \Illuminate\Support\Carbon $updated_at
 *
 * @property-read Service $service
 * @property-read Power $power
 * @property-read City $city
 * @property-read Status $getStatus
 */
class ServiceRequest extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'service_id',
        'power_id',
        'city_id',
        'comment',
        'user_id',
        'phone',
        'full_name',
        'status',
        'problem_id'
    ];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function getStatus()
    {
        return $this->belongsTo(Status::class, 'status', 'slug');
    }

    public function service()
    {
        return $this->belongsTo(Service::class);
    }

    public function problem()
    {
        return $this->belongsTo(Problem::class, 'problem_id');
    }

    public function power()
    {
        return $this->belongsTo(Power::class);
    }

    public function city()
    {
        return $this->belongsTo(City::class);
    }
}
