File "StoreOfficeSupplyRequest.php"

Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Http/Requests/Admin/StoreOfficeSupplyRequest.php
File size: 1.46 KB
MIME-type: text/x-php
Charset: utf-8

<?php

namespace App\Http\Requests\Admin;

use App\Models\OfficeSupplies;
use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Http\FormRequest;

class StoreOfficeSupplyRequest extends FormRequest
{
    public function authorize()
    {
        return Gate::allows('office_supplies_create');
    }

    public function rules()
    {
        return [
            'vendor_id' => [
                'required',
                'integer',
                'exists:vendors,id',
            ],
            'sku' => [
                'string',
                'max:50',
                'required',
                'unique:office_supplies',
            ],
            'name' => [
                'string',
                'max:50',
                'required',
            ],
            'description' => [
                'string',
                'nullable',
                'max:2055',
            ],
            'featured_image' => [
                'nullable',
                'mimes:jpg,gif,png',
                'max:5120',
            ],
            'status' => [
                'required',
                'integer',
                'in:'. implode(',', array_keys(OfficeSupplies::STATUS_RADIO)),
            ],
        ];
    }

    public function messages()
    {
        return [
            'featured_image.uploaded' => "The featured image must not be greater than 5MB.",
            'featured_image.max' => "The featured image must not be greater than 5MB.",
        ];
    }
}