2026-01-15 01:13:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
2026-01-17 17:44:37 +00:00
|
|
|
use Illuminate\Validation\Rule;
|
2026-01-15 01:13:44 +00:00
|
|
|
|
|
|
|
|
class StoreMediaRequest extends FormRequest
|
|
|
|
|
{
|
2026-01-17 17:44:37 +00:00
|
|
|
protected array $allowedModels = [
|
2026-01-21 20:57:15 +00:00
|
|
|
'postPlatform',
|
|
|
|
|
'workspace',
|
|
|
|
|
'user',
|
2026-01-17 17:44:37 +00:00
|
|
|
];
|
|
|
|
|
|
2026-01-15 01:13:44 +00:00
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function rules(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
2026-01-17 17:44:37 +00:00
|
|
|
'media' => [
|
2026-01-15 01:13:44 +00:00
|
|
|
'required',
|
|
|
|
|
'file',
|
|
|
|
|
'max:512000', // 500MB
|
|
|
|
|
'mimetypes:image/jpeg,image/png,image/gif,image/webp,video/mp4,video/quicktime,video/webm,application/pdf',
|
|
|
|
|
],
|
2026-01-17 17:44:37 +00:00
|
|
|
'model' => [
|
|
|
|
|
'required',
|
|
|
|
|
'string',
|
|
|
|
|
Rule::in($this->allowedModels),
|
|
|
|
|
],
|
|
|
|
|
'model_id' => [
|
|
|
|
|
'required',
|
|
|
|
|
'string',
|
|
|
|
|
],
|
|
|
|
|
'collection' => [
|
|
|
|
|
'sometimes',
|
|
|
|
|
'string',
|
|
|
|
|
'max:255',
|
|
|
|
|
],
|
2026-01-15 01:13:44 +00:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function messages(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
2026-01-17 17:44:37 +00:00
|
|
|
'media.required' => 'The file is required.',
|
|
|
|
|
'media.max' => 'The file must be at most 500MB.',
|
|
|
|
|
'media.mimetypes' => 'File type not supported.',
|
|
|
|
|
'model.required' => 'The model is required.',
|
|
|
|
|
'model.in' => 'Invalid model type.',
|
|
|
|
|
'model_id.required' => 'The model ID is required.',
|
2026-01-15 01:13:44 +00:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|