First Commit

This commit is contained in:
marco
2026-09-01 09:22:30 -03:00
commit a43ae23eb4
407 changed files with 36138 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\AiProvider;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreAiProviderRequest 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:255', Rule::unique('ai_providers', 'name')->whereNull('deleted_at')],
'slug' => ['required', 'string', 'max:255', Rule::unique('ai_providers', 'slug')->whereNull('deleted_at')],
'description' => ['nullable', 'string'],
'api_key' => ['required', 'string', 'max:255'],
'base_url' => ['required', 'url', 'max:255'],
'is_active' => ['boolean'],
'config' => ['nullable', 'array'],
];
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\AiProvider;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateAiProviderRequest 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:255', Rule::unique('ai_providers', 'name')->ignore($this->route('ai_provider'))],
'slug' => ['sometimes', 'string', 'max:255', Rule::unique('ai_providers', 'slug')->ignore($this->route('ai_provider'))],
'description' => ['nullable', 'string'],
'api_key' => ['sometimes', 'string', 'max:255'],
'base_url' => ['sometimes', 'url', 'max:255'],
'is_active' => ['boolean'],
'config' => ['nullable', 'array'],
];
}
}
+126
View File
@@ -0,0 +1,126 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\Auth;
use App\Rules\Captcha;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
/**
* Form request for user login with arithmetic captcha validation.
*/
class LoginRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'email' => ['required', 'string', 'email'],
'password' => ['required', 'string'],
'captcha' => ['required', 'string', 'max:4', new Captcha()],
];
}
/**
* Get custom messages for validator errors.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'email.required' => 'O e-mail é obrigatório.',
'email.email' => 'Informe um e-mail válido.',
'password.required' => 'A senha é obrigatória.',
'captcha.required' => 'O captcha é obrigatório.',
'captcha.size' => 'O captcha deve ter :size caracteres.',
'captcha' => 'O captcha informado está incorreto.',
];
}
/**
* Get custom attributes for validator errors.
*
* @return array<string, string>
*/
public function attributes(): array
{
return [
'email' => 'e-mail',
'password' => 'senha',
'captcha' => 'captcha',
];
}
/**
* Attempt to authenticate the request's credentials.
*
* @throws ValidationException
*/
public function authenticate(): void
{
$this->ensureIsNotRateLimited();
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
RateLimiter::hit($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.failed'),
]);
}
RateLimiter::clear($this->throttleKey());
}
/**
* Ensure the login request is not rate limited.
*
* @throws ValidationException
*/
public function ensureIsNotRateLimited(): void
{
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
return;
}
event(new Lockout($this));
$seconds = RateLimiter::availableIn($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.throttle', [
'seconds' => $seconds,
'minutes' => ceil($seconds / 60),
]),
]);
}
/**
* Get the rate limiting throttle key for the request.
*/
public function throttleKey(): string
{
return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip());
}
}
+84
View File
@@ -0,0 +1,84 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\Auth;
use App\Rules\Captcha;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Password;
/**
* Form request for user registration with arithmetic captcha validation.
*/
class RegisterRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:users,email'],
'password' => ['required', 'confirmed', Password::defaults()],
'captcha' => ['required', 'string', 'max:4', new Captcha()],
'terms_of_service' => ['required', 'accepted'],
'privacy_policy' => ['required', 'accepted'],
];
}
/**
* Get custom messages for validator errors.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'name.required' => 'O nome é obrigatório.',
'name.max' => 'O nome não pode ultrapassar 255 caracteres.',
'email.required' => 'O e-mail é obrigatório.',
'email.email' => 'Informe um e-mail válido.',
'email.unique' => 'Este e-mail já está cadastrado.',
'password.required' => 'A senha é obrigatória.',
'password.confirmed' => 'A confirmação de senha não confere.',
'captcha.required' => 'O captcha é obrigatório.',
'captcha.size' => 'O captcha deve ter :size caracteres.',
'captcha' => 'O captcha informado está incorreto.',
'terms_of_service.accepted' => 'Você deve aceitar os Termos de Uso para continuar.',
'privacy_policy.accepted' => 'Você deve aceitar a Política de Privacidade para continuar.',
];
}
/**
* Get custom attributes for validator errors.
*
* @return array<string, string>
*/
public function attributes(): array
{
return [
'name' => 'nome',
'email' => 'e-mail',
'password' => 'senha',
'password_confirmation' => 'confirmação de senha',
'captcha' => 'captcha',
'terms_of_service' => 'Termos de Uso',
'privacy_policy' => 'Política de Privacidade',
];
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests;
use App\Models\User;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ProfileUpdateRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'email' => [
'required',
'string',
'lowercase',
'email',
'max:255',
Rule::unique(User::class)->ignore($this->user()->id),
],
];
}
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\PromptGeneration;
use Illuminate\Foundation\Http\FormRequest;
class GeneratePromptRequest 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 [
'project_id' => ['required', 'exists:prompt_projects,id'],
'provider_id' => ['required', 'exists:ai_providers,id'],
'model_id' => ['required', 'exists:ai_models,id'],
'temperature' => ['nullable', 'numeric', 'min:0', 'max:1'],
'max_tokens' => ['nullable', 'integer', 'min:1'],
];
}
}
@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\PromptProject;
use Illuminate\Foundation\Http\FormRequest;
class StorePromptProjectRequest 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'],
'company_name' => ['nullable', 'string', 'max:255'],
'company_address' => ['nullable', 'string'],
'company_whatsapp' => ['nullable', 'string', 'max:255'],
'company_website' => ['nullable', 'url', 'max:255'],
'company_social_media' => ['nullable', 'string'],
'company_business_activities' => ['nullable', 'string'],
'company_services_products' => ['nullable', 'string'],
'objective' => ['required', 'string'],
'context' => ['nullable', 'string'],
'persona' => ['nullable', 'string', 'max:255'],
'tone' => ['nullable', 'string', 'max:255'],
'constraints' => ['nullable', 'string'],
'output_format' => ['nullable', 'string'],
'examples' => ['nullable', 'string'],
'variables' => ['nullable', 'string'],
'temperature' => ['nullable', 'numeric', 'min:0', 'max:1'],
'max_tokens' => ['nullable', 'integer', 'min:1'],
'provider_id' => ['nullable', 'exists:ai_providers,id'],
'model_id' => ['nullable', 'exists:ai_models,id'],
];
}
}
@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\PromptProject;
use Illuminate\Foundation\Http\FormRequest;
class UpdatePromptProjectRequest 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'],
'company_name' => ['nullable', 'string', 'max:255'],
'company_address' => ['nullable', 'string'],
'company_whatsapp' => ['nullable', 'string', 'max:255'],
'company_website' => ['nullable', 'url', 'max:255'],
'company_social_media' => ['nullable', 'string'],
'company_business_activities' => ['nullable', 'string'],
'company_services_products' => ['nullable', 'string'],
'objective' => ['sometimes', 'string'],
'context' => ['nullable', 'string'],
'persona' => ['nullable', 'string', 'max:255'],
'tone' => ['nullable', 'string', 'max:255'],
'constraints' => ['nullable', 'string'],
'output_format' => ['nullable', 'string'],
'examples' => ['nullable', 'string'],
'variables' => ['nullable', 'string'],
'temperature' => ['nullable', 'numeric', 'min:0', 'max:1'],
'max_tokens' => ['nullable', 'integer', 'min:1'],
'provider_id' => ['nullable', 'exists:ai_providers,id'],
'model_id' => ['nullable', 'exists:ai_models,id'],
];
}
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\PromptTemplate;
use Illuminate\Foundation\Http\FormRequest;
class StorePromptTemplateRequest 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:255'],
'description' => ['nullable', 'string', 'max:1000'],
'category' => ['nullable', 'string', 'max:255'],
'template_data' => ['required', 'string'],
'is_public' => ['boolean'],
];
}
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\PromptTemplate;
use Illuminate\Foundation\Http\FormRequest;
class UpdatePromptTemplateRequest 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:255'],
'description' => ['nullable', 'string', 'max:1000'],
'category' => ['nullable', 'string', 'max:255'],
'template_data' => ['required', 'string'],
'is_public' => ['boolean'],
];
}
}