<?php

namespace App\Modules\Bookings;

use App\Models\ValidationModel;

class TaskSubtype extends ValidationModel
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['name', 'for'];

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'task_subtypes';

    /**
     * Array of validation rules.
     *
     * @var  array
     */
    protected static $rules = [
        'name' => 'required',
        'for'  => 'required|in:repair,support,onsite',
    ];

    /**
     * Returns all the subtypes for repairs.
     */
    public function scopeRepair($query)
    {
        return $query->where('for', 'repair')->orWhere('for', 'all');
    }

    /**
     * Returns all the subtypes for remote support.
     */
    public function scopeSupport($query)
    {
        return $query->where('for', 'support')->orWhere('for', 'all');
    }

    /**
     * Returns all the subtypes for oniste.
     */
    public function scopeOnsite($query)
    {
        return $query->where('for', 'onsite')->orWhere('for', 'all');
    }

    /**
     * Returns all the subtypes for orders.
     */
    public function scopeOrders($query)
    {
        return $query->where('for', 'orders')->orWhere('for', 'all');
    }

    /**
     * Returns all the subtypes for rma.
     */
    public function scopeRma($query)
    {
        return $query->where('for', 'rma')->orWhere('for', 'all');
    }

    /**
     * nadeem
     * Static method to get all subtypes
     */
    public static function getAllSubtypes($query)
    {

    }
}
