<?php

namespace App\Models;

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

class Shippingzone extends Model
{
    use HasFactory;
    protected $table = 'shipping_zone';
    protected $fillable = [
        'id',
        'zone_name',
        'service_name',
        'price',
        'status',
    ];

    public function areas()
    {
        return $this->hasMany(Area::class, 'serviceid', 'id');
    }

    protected static function boot()
    {
        parent::boot();

        static::deleting(function ($shippingZone) {
            $shippingZone->areas()->delete();
        });
    }
}
