36 lines
872 B
PHP
36 lines
872 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Master;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class SupplierRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()->can('suppliers.create')
|
|
|| $this->user()->can('suppliers.update');
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$supplier = $this->route('supplier');
|
|
|
|
return [
|
|
'name' => ['required', 'string', 'max:200', Rule::unique('suppliers', 'name')->ignore($supplier)],
|
|
'phone_number' => ['nullable', 'string', 'max:20'],
|
|
'address' => ['nullable', 'string'],
|
|
];
|
|
}
|
|
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'name' => 'nama',
|
|
'phone_number' => 'nomor telepon',
|
|
'address' => 'alamat',
|
|
];
|
|
}
|
|
}
|