first
This commit is contained in:
52
app/Http/Requests/User/CreateProjectRequest.php
Normal file
52
app/Http/Requests/User/CreateProjectRequest.php
Normal 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.',
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Requests/User/StoreCommentRequest.php
Normal file
28
app/Http/Requests/User/StoreCommentRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreCommentRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'message' => ['required', 'string', 'max:2000'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'message.required' => 'Mesej komen tidak boleh kosong.',
|
||||
'message.max' => 'Mesej terlalu panjang (maks 2,000 aksara).',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/User/UpdateTranscriptRequest.php
Normal file
30
app/Http/Requests/User/UpdateTranscriptRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateTranscriptRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true; // Policy diperiksa dalam controller
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'transcript_text' => ['required', 'string', 'max:500000'],
|
||||
'change_summary' => ['nullable', 'string', 'max:500'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'transcript_text.required' => 'Teks transkripsi tidak boleh kosong.',
|
||||
'transcript_text.max' => 'Teks transkripsi terlalu panjang (maks 500,000 aksara).',
|
||||
'change_summary.max' => 'Ringkasan perubahan terlalu panjang (maks 500 aksara).',
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Requests/User/UploadExternalTranscriptRequest.php
Normal file
32
app/Http/Requests/User/UploadExternalTranscriptRequest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\User;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UploadExternalTranscriptRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'transcript_file' => ['required', 'file', 'mimetypes:text/plain', 'extensions:txt', 'max:10240'],
|
||||
'clean_with_ollama' => ['nullable', 'boolean'],
|
||||
'confirmed' => ['nullable', 'boolean'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'transcript_file.required' => 'Sila pilih fail transkripsi (.txt).',
|
||||
'transcript_file.mimetypes' => 'Fail mesti berformat teks biasa (.txt).',
|
||||
'transcript_file.extensions'=> 'Hanya fail .txt dibenarkan.',
|
||||
'transcript_file.max' => 'Saiz fail terlalu besar (maks 10 MB).',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user