<?php

namespace App\Models;

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


class Recompense extends GenericModel
{
    protected $table = 'recompenses';
    protected $primaryKey = 'id';
    protected $label = 'Recompenses';
    protected $sub_label = 'List of  Recompense';

    protected $fields = [
        'brand' =>'Brands',
        'designation'=>'Designation',
        'description'=>'Description',
        'nombre_points'=>'Nombre Points',
        'message'=>'Message',
        'is_active'=>'Active',
    ];

    protected $actions = ['add','edit','delete'];
    protected $columns_hiddens = ['url', 'icon'];

    protected $belongsTo = [
        'brand'=>[Brand::class,'brand_id','nom'],
    ];

    protected $selects = ['is_active'=>[1=>'Yes',0=>'No']];
    protected $numbers = ['sequence'];
    protected $longTexts  = ['message'];

    public static function validate($request){
        $rules = [
            'designation' => 'required',
            'nombre_points' => 'required',
        ];
        $messages = [];
        return Validator::make($request->input(),$rules,$messages);
    }

    public function brand(){
        return $this->belongsTo(Brand::class,'brand_id');
    }

}
