<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Continent extends Model
{
    protected $fillable = [
        'name',
        'code',
        'status',
    ];

    protected $casts = [
        'status' => 'integer',
    ];

    /**
     * Countries reference this continent by storing continents.name in countries.continent (varchar).
     */
    public function countries()
    {
        return $this->hasMany(Country::class, 'continent', 'name');
    }

    public function scopeActive($query)
    {
        return $query->where('status', 1);
    }
}
