chore: commit remaining workspace changes
This commit is contained in:
53
app/Http/Requests/Academy/UpsertAcademyCourseRequest.php
Normal file
53
app/Http/Requests/Academy/UpsertAcademyCourseRequest.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Academy;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpsertAcademyCourseRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return (bool) $this->user()?->hasStaffAccess();
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'is_featured' => $this->boolean('is_featured'),
|
||||
'order_num' => $this->filled('order_num') ? (int) $this->input('order_num') : 0,
|
||||
'estimated_minutes' => $this->filled('estimated_minutes') ? (int) $this->input('estimated_minutes') : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$courseId = $this->route('academyCourse')?->id;
|
||||
|
||||
return [
|
||||
'title' => ['required', 'string', 'max:180'],
|
||||
'slug' => ['required', 'string', 'max:180', Rule::unique('academy_courses', 'slug')->ignore($courseId)],
|
||||
'subtitle' => ['nullable', 'string', 'max:255'],
|
||||
'excerpt' => ['nullable', 'string'],
|
||||
'description' => ['nullable', 'string'],
|
||||
'cover_image' => ['nullable', 'string', 'max:2048'],
|
||||
'teaser_image' => ['nullable', 'string', 'max:2048'],
|
||||
'access_level' => ['required', 'string', Rule::in(['free', 'premium', 'mixed'])],
|
||||
'difficulty' => ['required', 'string', Rule::in(['beginner', 'intermediate', 'advanced'])],
|
||||
'status' => ['required', 'string', Rule::in(['draft', 'review', 'published', 'archived'])],
|
||||
'is_featured' => ['required', 'boolean'],
|
||||
'order_num' => ['required', 'integer', 'min:0'],
|
||||
'estimated_minutes' => ['nullable', 'integer', 'min:1', 'max:10000'],
|
||||
'published_at' => ['nullable', 'date'],
|
||||
'seo_title' => ['nullable', 'string', 'max:180'],
|
||||
'seo_description' => ['nullable', 'string', 'max:255'],
|
||||
'meta_keywords' => ['nullable', 'string'],
|
||||
'og_title' => ['nullable', 'string', 'max:180'],
|
||||
'og_description' => ['nullable', 'string', 'max:255'],
|
||||
'og_image' => ['nullable', 'string', 'max:2048'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,18 @@ class UpsertAcademyLessonRequest extends FormRequest
|
||||
->all();
|
||||
|
||||
$this->merge([
|
||||
'lesson_number' => $this->filled('lesson_number') ? (int) $this->input('lesson_number') : null,
|
||||
'course_order' => $this->filled('course_order') ? (int) $this->input('course_order') : null,
|
||||
'content_source' => in_array((string) $this->input('content_source'), ['html', 'markdown'], true)
|
||||
? (string) $this->input('content_source')
|
||||
: ($this->filled('content_markdown') ? 'markdown' : 'html'),
|
||||
'course_ids' => collect($this->input('course_ids', []))
|
||||
->filter(static fn ($courseId): bool => filled($courseId))
|
||||
->map(static fn ($courseId): int => (int) $courseId)
|
||||
->unique()
|
||||
->values()
|
||||
->all(),
|
||||
'tags' => array_values(array_filter((array) $this->input('tags', []))),
|
||||
'reading_minutes' => $this->filled('reading_minutes') ? (int) $this->input('reading_minutes') : 5,
|
||||
'featured' => $this->boolean('featured'),
|
||||
'active' => $this->boolean('active', true),
|
||||
@@ -84,12 +96,22 @@ class UpsertAcademyLessonRequest extends FormRequest
|
||||
'category_id' => ['nullable', 'integer', 'exists:academy_categories,id'],
|
||||
'title' => ['required', 'string', 'max:180'],
|
||||
'slug' => ['required', 'string', 'max:180', Rule::unique('academy_lessons', 'slug')->ignore($lessonId)],
|
||||
'lesson_number' => ['nullable', 'integer', 'min:1'],
|
||||
'course_order' => ['nullable', 'integer', 'min:1'],
|
||||
'course_ids' => ['nullable', 'array'],
|
||||
'course_ids.*' => ['integer', 'exists:academy_courses,id'],
|
||||
'series_name' => ['nullable', 'string', 'max:120'],
|
||||
'excerpt' => ['nullable', 'string'],
|
||||
'content' => ['nullable', 'string'],
|
||||
'content_markdown' => ['nullable', 'string'],
|
||||
'content_source' => ['required', 'string', Rule::in(['html', 'markdown'])],
|
||||
'difficulty' => ['required', 'string', Rule::in((array) config('academy.difficulty_levels', []))],
|
||||
'access_level' => ['required', 'string', Rule::in(['free', 'creator', 'pro'])],
|
||||
'lesson_type' => ['required', 'string', 'max:80'],
|
||||
'cover_image' => ['nullable', 'string', 'max:2048'],
|
||||
'article_cover_image' => ['nullable', 'string', 'max:2048'],
|
||||
'tags' => ['nullable', 'array'],
|
||||
'tags.*' => ['string', 'max:60'],
|
||||
'video_url' => ['nullable', 'string', 'max:2048'],
|
||||
'reading_minutes' => ['required', 'integer', 'min:1', 'max:999'],
|
||||
'featured' => ['required', 'boolean'],
|
||||
|
||||
@@ -20,8 +20,31 @@ class UpsertAcademyPromptTemplateRequest extends FormRequest
|
||||
'featured' => $this->boolean('featured'),
|
||||
'prompt_of_week' => $this->boolean('prompt_of_week'),
|
||||
'active' => $this->boolean('active', true),
|
||||
'new_category_name' => trim((string) $this->input('new_category_name', '')),
|
||||
'tags' => array_values(array_filter((array) $this->input('tags', []))),
|
||||
'tool_notes' => (array) $this->input('tool_notes', []),
|
||||
'tool_notes' => collect($this->input('tool_notes', []))
|
||||
->filter(static fn ($note): bool => is_array($note) || is_string($note))
|
||||
->map(function ($note): array|string {
|
||||
if (is_string($note)) {
|
||||
return $note;
|
||||
}
|
||||
|
||||
return [
|
||||
'provider' => $note['provider'] ?? null,
|
||||
'model_name' => $note['model_name'] ?? null,
|
||||
'notes' => $note['notes'] ?? null,
|
||||
'strengths' => $note['strengths'] ?? null,
|
||||
'weaknesses' => $note['weaknesses'] ?? null,
|
||||
'best_for' => $note['best_for'] ?? null,
|
||||
'image_path' => $note['image_path'] ?? null,
|
||||
'thumb_path' => $note['thumb_path'] ?? null,
|
||||
'settings' => $note['settings'] ?? null,
|
||||
'score' => filled($note['score'] ?? null) ? (int) $note['score'] : null,
|
||||
'active' => filter_var($note['active'] ?? true, FILTER_VALIDATE_BOOL, FILTER_NULL_ON_FAILURE) ?? true,
|
||||
];
|
||||
})
|
||||
->values()
|
||||
->all(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -31,6 +54,7 @@ class UpsertAcademyPromptTemplateRequest extends FormRequest
|
||||
|
||||
return [
|
||||
'category_id' => ['nullable', 'integer', 'exists:academy_categories,id'],
|
||||
'new_category_name' => ['nullable', 'string', 'max:120'],
|
||||
'title' => ['required', 'string', 'max:180'],
|
||||
'slug' => ['required', 'string', 'max:180', Rule::unique('academy_prompt_templates', 'slug')->ignore($promptId)],
|
||||
'excerpt' => ['nullable', 'string'],
|
||||
@@ -44,6 +68,17 @@ class UpsertAcademyPromptTemplateRequest extends FormRequest
|
||||
'tags' => ['nullable', 'array'],
|
||||
'tags.*' => ['string', 'max:60'],
|
||||
'tool_notes' => ['nullable', 'array'],
|
||||
'tool_notes.*.provider' => ['nullable', 'string', 'max:100'],
|
||||
'tool_notes.*.model_name' => ['nullable', 'string', 'max:150'],
|
||||
'tool_notes.*.notes' => ['nullable', 'string'],
|
||||
'tool_notes.*.strengths' => ['nullable', 'string'],
|
||||
'tool_notes.*.weaknesses' => ['nullable', 'string'],
|
||||
'tool_notes.*.best_for' => ['nullable', 'string'],
|
||||
'tool_notes.*.image_path' => ['nullable', 'string', 'max:500'],
|
||||
'tool_notes.*.thumb_path' => ['nullable', 'string', 'max:500'],
|
||||
'tool_notes.*.settings' => ['nullable', 'string'],
|
||||
'tool_notes.*.score' => ['nullable', 'integer', 'min:1', 'max:10'],
|
||||
'tool_notes.*.active' => ['nullable', 'boolean'],
|
||||
'preview_image' => ['nullable', 'string', 'max:2048'],
|
||||
'preview_image_file' => ['nullable', 'file', 'image', 'mimes:jpg,jpeg,png,webp', 'max:5120'],
|
||||
'featured' => ['required', 'boolean'],
|
||||
|
||||
Reference in New Issue
Block a user