This commit is contained in:
Saufi
2026-06-02 17:35:45 +08:00
commit 4ef99b1f81
148 changed files with 21134 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
<?php
namespace App\Http\Requests\User;
use App\Rules\ValidAudioMagicBytes;
use Illuminate\Foundation\Http\FormRequest;
class CreateProjectRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user()->isActive();
}
public function rules(): array
{
$maxKb = config('speech2text.upload.max_mb', 200) * 1024;
$extensions = implode(',', config('speech2text.upload.allowed_extensions'));
return [
'title' => ['required', 'string', 'max:255'],
'description' => ['nullable', 'string', 'max:2000'],
'audio' => [
'required',
'file',
"mimes:{$extensions}",
"max:{$maxKb}",
new ValidAudioMagicBytes(),
],
'language' => ['nullable', 'string', 'in:ms,en'],
];
}
public function attributes(): array
{
return [
'title' => 'Tajuk projek',
'description' => 'Penerangan',
'audio' => 'Fail audio',
'language' => 'Bahasa',
];
}
public function messages(): array
{
$maxMb = config('speech2text.upload.max_mb', 200);
return [
'audio.max' => "Saiz fail audio melebihi had maksimum {$maxMb}MB.",
'audio.mimes' => 'Format fail tidak disokong. Guna: mp3, wav, m4a, mp4, aac, ogg, flac, webm.',
];
}
}