<?php

namespace App\Models;

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

class Asset extends Model
{
    use HasFactory;
    
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'assets';

    /**
    * The database primary key value.
    *
    * @var string
    */
    protected $primaryKey = 'id';

    /**
     * Attributes that should be mass-assignable.
     *
     * @var array
     */
    protected $fillable = [
        'vendor_id',
        'category_id',
        'name', 
        'model_name', 
        'model_number', 
        'registered_number', 
        'brand', 
        'duration',  
        'asset_type', 
        'cost', 
        'description', 
        'image', 
        'weight', 
        'size', 
        'return_policy', 
        'status',
        'meta_keyword',
        'meta_description',
        'created_by',
    ];
    public function validate($request){
        $validate = Validator::make($request->all(), [
            'name' => 'required',
            'cost' => 'required',
        ]);
        if($validate->fails()){
            return response()->json([
                'status' => false,
                'message' => 'Validation errors in your request',
                'errors' => $validate->errors()
            ], 400);
        }
        return response()->json([
            'status' => true,
            'message' => 'sucess',
            'errors' => ''
        ], 200);
    }
}
