<?php

namespace App\Models;

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

class Service extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'name_ar',
        'name_en',
        'type',
        'price',
        'description_ar',
        'description_en',
    ];

    public function getNameAttribute()
    {
        return app()->getLocale() == 'ar' ? $this->name_ar : ($this->name_en ?: $this->name_ar);
    }

    public function getDescriptionAttribute()
    {
        return app()->getLocale() == 'ar' ? $this->description_ar : ($this->description_en ?: $this->description_ar);
    }

    public function subscriptions()
    {
        return $this->hasMany(ServiceSubscription::class);
    }
}
