<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Validator;


class TypeOperation extends GenericModel {
    
    use HasFactory;

    protected $table = 'type_operations';
    protected $primaryKey = 'id';
    protected $label = 'Type Of Operations';
    protected $sub_label = 'Type Of Operations';
    protected $fields = [
        'id'=>'ID',
        'nom'=>'Name',
        'points'=>'Points',
    ];

    protected $orderBys = ['nom'=>'asc'];
    protected $actions = ['edit','add','delete'];
    protected $formRequireds = [ 'nom'];
    protected $hidden = ['id'];
    protected $fields_hiddens = ['id'];
    //protected $view_form = 'inc.cruds.simple_form';
    //protected $form_size = 'col-xl-6';
    //protected $view_list = 'inc.cruds.list';

    

    public static function validate($request){
        $rules = [
            'nom' => 'required|unique:type_operations,nom,'.$request->get('_id'),
        ];
        $messages = [
        ];
        return Validator::make($request->input(),$rules,$messages);
    }

    public function getTitle()
    {
        return ' ';
    }

    
}