Estado inicial: frontend React + backend Laravel
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateCategoryRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|max:50|unique:categories,name',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => 'O nome é obrigatório',
|
||||
'name.max' => 'O nome deve ter no máximo 50 caracteres',
|
||||
'name.unique' => 'A categoria já existe',
|
||||
];
|
||||
}
|
||||
}
|
||||
49
plataforma-tutorias/app/Http/Requests/CreateUserRequest.php
Normal file
49
plataforma-tutorias/app/Http/Requests/CreateUserRequest.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateUserRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|max:50|min:3',
|
||||
'email' => 'required|email|unique:users,email',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
'role_id' => 'required|exists:roles,id',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => 'O nome é obrigatório',
|
||||
'name.max' => 'O nome deve ter no máximo 50 caracteres',
|
||||
'name.min' => 'O nome deve ter pelo menos 3 caracteres',
|
||||
'email.required' => 'O email é obrigatório',
|
||||
'email.email' => 'O email deve ser um email válido',
|
||||
'email.unique' => 'O email já está em uso',
|
||||
'role_id.required' => 'Obrigatório selecionar um cargo',
|
||||
'role_id.exists' => 'Cargo não encontrado',
|
||||
'password.required' => 'A password é obrigatória',
|
||||
'password.min' => 'A password deve ter pelo menos 6 caracteres',
|
||||
'password.confirmed' => 'As passwords não coincidem',
|
||||
];
|
||||
}
|
||||
}
|
||||
52
plataforma-tutorias/app/Http/Requests/CreateVideoRequest.php
Normal file
52
plataforma-tutorias/app/Http/Requests/CreateVideoRequest.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateVideoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'required|string|max:255',
|
||||
'description' => 'required|string|max:3000',
|
||||
'url' => 'required|file|mimes:mp4,mov,avi,wmv,flv,mpeg,mpg,m4v,3gp,3g2,mj2|max:512000', // 500MB
|
||||
'thumbnail' => 'required|image|mimes:jpg,jpeg,png,webp|max:4000',
|
||||
'duration' => 'nullable|string|max:10',
|
||||
'tags' => 'nullable|string|max:255', // nullable para não ser obrigatório
|
||||
'category_ids' => 'nullable|array|exists:categories,id', // nullable caso não selecione
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'title.required' => 'O título é obrigatório',
|
||||
'title.max' => 'O título deve ter no máximo 255 caracteres',
|
||||
'description.required' => 'A descrição é obrigatória',
|
||||
'description.max' => 'A descrição deve ter no máximo 3000 caracteres',
|
||||
'url.required' => 'A URL é obrigatória',
|
||||
'url.mimes' => 'A URL deve ser um arquivo de vídeo',
|
||||
'url.max' => 'A URL deve ter no máximo 500 caracteres',
|
||||
'thumbnail.required' => 'A thumbnail é obrigatória',
|
||||
'thumbnail.mimes' => 'Ficheiro de imagem inválido: deve ser jpg, jpeg, png ou webp',
|
||||
'thumbnail.max' => 'A thumbnail deve ter no máximo 4MB',
|
||||
'tags.max' => 'As tags devem ter no máximo 50 caracteres',
|
||||
'category_id.exists' => 'A categoria não existe',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateWorkshopRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'required|string|max:255',
|
||||
'description' => 'required|string|max:3000',
|
||||
'image' => 'required|image|mimes:jpg,jpeg,png,webp|max:2048',
|
||||
'date' => 'required|date',
|
||||
'time_start' => 'required|date_format:H:i',
|
||||
'time_end' => 'required|date_format:H:i',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'title.required' => 'O título é obrigatório',
|
||||
'title.max' => 'O título deve ter no máximo 255 caracteres',
|
||||
'description.max' => 'A descrição deve ter no máximo 3000 caracteres',
|
||||
'image.mimes' => 'O ficheiro deve ser do formato jpg, jpeg, png ou webp',
|
||||
'image.max' => 'A imagem deve ter no máximo 2MB',
|
||||
'date.required' => 'A data é obrigatória',
|
||||
'date.date' => 'A data deve ser uma data válida',
|
||||
'time_start.required' => 'A hora de início é obrigatória',
|
||||
'time_start.time' => 'A hora de início deve ser uma hora válida',
|
||||
'time_end.required' => 'A hora de término é obrigatória',
|
||||
'time_end.time' => 'A hora de término deve ser uma hora válida',
|
||||
];
|
||||
}
|
||||
}
|
||||
39
plataforma-tutorias/app/Http/Requests/LoginRequest.php
Normal file
39
plataforma-tutorias/app/Http/Requests/LoginRequest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class LoginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|min:6',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'email.required' => 'O email é obrigatório',
|
||||
'email.email' => 'O email deve ser um email válido',
|
||||
'password.required' => 'A password é obrigatória',
|
||||
'password.min' => 'A password deve ter pelo menos 6 caracteres',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateCategoryRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'sometimes|string|max:50|unique:categories,name',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.max' => 'O nome deve ter no máximo 50 caracteres',
|
||||
'name.unique' => 'A categoria já existe',
|
||||
];
|
||||
}
|
||||
}
|
||||
48
plataforma-tutorias/app/Http/Requests/UpdateUserRequest.php
Normal file
48
plataforma-tutorias/app/Http/Requests/UpdateUserRequest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateUserRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$userId = $this->route('id');
|
||||
|
||||
return [
|
||||
'name' => 'sometimes|string|max:50|min:3',
|
||||
'email' => [
|
||||
'sometimes',
|
||||
'email',
|
||||
Rule::unique('users', 'email')->ignore($userId),
|
||||
],
|
||||
'role_id' => 'sometimes|exists:roles,id',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.max' => 'O nome deve ter no máximo 50 caracteres',
|
||||
'name.min' => 'O nome deve ter pelo menos 3 caracteres',
|
||||
'email.email' => 'O email deve ser um email válido',
|
||||
'email.unique' => 'O email já está em uso',
|
||||
'role_id.exists' => 'Cargo não encontrado',
|
||||
];
|
||||
}
|
||||
}
|
||||
47
plataforma-tutorias/app/Http/Requests/UpdateVideoRequest.php
Normal file
47
plataforma-tutorias/app/Http/Requests/UpdateVideoRequest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateVideoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'sometimes|string|max:255',
|
||||
'description' => 'sometimes|string|max:3000',
|
||||
'url' => 'sometimes|string|max:500',
|
||||
'thumbnail' => 'sometimes|file|mimes:jpg,jpeg,png,webp|max:4000',
|
||||
'tags' => 'sometimes|string|max:100',
|
||||
'category_ids' => 'sometimes|array',
|
||||
'category_ids.*' => 'exists:categories,id',
|
||||
'is_active' => 'sometimes|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'title.max' => 'O título deve ter no máximo 255 caracteres',
|
||||
'description.max' => 'A descrição deve ter no máximo 3000 caracteres',
|
||||
'url.max' => 'A URL deve ter no máximo 500 caracteres',
|
||||
'thumbnail.mimes' => 'O ficheiro deve ser do formato jpg, jpeg, png ou webp',
|
||||
'thumbnail.max' => 'A thumbnail deve ter no máximo 4MB',
|
||||
'category_id.exists' => 'A categoria não existe',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateWorkshopRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'sometimes|string|max:255',
|
||||
'description' => 'sometimes|string|max:3000',
|
||||
'image' => 'sometimes|image|mimes:jpg,jpeg,png,webp|max:2048',
|
||||
'date' => 'sometimes|date',
|
||||
'time_start' => 'sometimes|date_format:H:i',
|
||||
'time_end' => 'sometimes|date_format:H:i',
|
||||
'is_active' => 'sometimes|boolean',
|
||||
'status' => 'sometimes|string|in:pending,realized,canceled',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'title.max' => 'O título deve ter no máximo 255 caracteres',
|
||||
'description.max' => 'A descrição deve ter no máximo 3000 caracteres',
|
||||
'image.mimes' => 'O ficheiro deve ser do formato jpg, jpeg, png ou webp',
|
||||
'image.max' => 'A imagem deve ter no máximo 2MB',
|
||||
'date.date' => 'A data deve ser uma data válida',
|
||||
'time_start.date_format' => 'A hora de início deve ser uma hora válida',
|
||||
'time_end.date_format' => 'A hora de término deve ser uma hora válida',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user