2024-07-04 12:50:11 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
|
|
|
|
use App\Models\Category;
|
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
|
|
|
|
class StoreAssetModelRequest extends ImageUploadRequest
|
|
|
|
{
|
2024-07-04 13:52:37 -07:00
|
|
|
|
2024-07-04 12:50:11 -07:00
|
|
|
/**
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
*/
|
|
|
|
public function authorize(): bool
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function prepareForValidation(): void
|
|
|
|
{
|
|
|
|
|
2024-07-04 13:14:58 -07:00
|
|
|
$this->category_type = Category::find($this->category_id)->category_type;
|
2024-07-04 13:52:37 -07:00
|
|
|
|
2024-07-04 12:50:11 -07:00
|
|
|
$this->merge([
|
2024-07-04 13:14:58 -07:00
|
|
|
'category_type' => $this->category_type,
|
2024-07-04 12:50:11 -07:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
*
|
|
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
|
|
*/
|
|
|
|
public function rules(): array
|
|
|
|
{
|
|
|
|
return array_merge(
|
2024-07-04 13:14:58 -07:00
|
|
|
['category_type' => 'required|in:asset'],
|
2024-07-04 12:50:11 -07:00
|
|
|
parent::rules(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function messages(): array
|
|
|
|
{
|
2024-07-04 13:52:37 -07:00
|
|
|
$messages = ['category_type.in' => trans('admin/models/message.invalid_category_type')];
|
2024-07-04 12:50:11 -07:00
|
|
|
return $messages;
|
|
|
|
}
|
|
|
|
}
|