<?php

namespace App\Models;

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

class Service extends Model
{
    use HasFactory;

    protected $fillable = [
        'created_by',
        'category_id',
        'name',
        'slug',
        'description',
        'logo',
        'is_active',
    ];

    protected $casts = [
        'is_active' => 'boolean',
    ];

    public function category()
    {
        return $this->belongsTo(Category::class);
    }

    public function creator()
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    public function plans()
    {
        return $this->hasMany(ServicePlan::class);
    }

    public function servicePlans()
    {
        return $this->hasMany(ServicePlan::class);
    }

    public function sharedSubscriptions()
    {
        return $this->hasMany(SharedSubscription::class);
    }
}
