<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class CarShowCategory extends Model
{
  protected $table = 'car_show_categories';
  protected static ?string $recordTitleAttribute = 'category_name';

  protected $fillable = [
  'category_name',
  'vehicle_type'
  ];

  protected function casts(): array
  {
      return [
          'vehicle_type' => 'boolean',
          'created_at' => 'datetime',
          'updated_at' => 'datetime',
      ];
  }
 
  public function vehicle()
  {
      return $this->hasMany(Vehicles::class, 'type');
  }
  public function showWinner()
  {
      return $this->hasMany(CarShowWinner::class, 'category');
  }

  public function scopeVehtype($query)
  {
      return $query->where('vehicle_type', 1)->orderBy('category_name');
  }
}
