diff --git a/app/Filament/Resources/ProjectResource/Widgets/RejectedProject.php b/app/Filament/Resources/ProjectResource/Widgets/RejectedProject.php index 3f278212..082f5212 100644 --- a/app/Filament/Resources/ProjectResource/Widgets/RejectedProject.php +++ b/app/Filament/Resources/ProjectResource/Widgets/RejectedProject.php @@ -4,11 +4,8 @@ namespace App\Filament\Resources\ProjectResource\Widgets; -use App\Enums\ProjectStatus; use App\Filament\Resources\ProjectResource\Actions\Tables\Projects\ApproveProjectAction; -use App\Filament\Resources\ProjectResource\Actions\Tables\Projects\RejectProjectAction; use App\Models\Project; -use Filament\Tables\Actions\Action; use Filament\Tables\Actions\EditAction; use Filament\Tables\Actions\ViewAction; use Illuminate\Database\Eloquent\Builder; diff --git a/app/Http/Controllers/Dashboard/ProjectController.php b/app/Http/Controllers/Dashboard/ProjectController.php index 173670f3..bb9296ce 100644 --- a/app/Http/Controllers/Dashboard/ProjectController.php +++ b/app/Http/Controllers/Dashboard/ProjectController.php @@ -48,14 +48,6 @@ public function store(StoreRequest $request) { $data = $request->validated(); $project = (new ProjectService(Project::class))->create($data); - $project->addAllMediaFromRequest()->each(function ($fileAdder, $index) { - if ($index == 0) { - $fileAdder->toMediaCollection('preview'); - } else { - $fileAdder->toMediaCollection('gallery'); - } - }); - return redirect()->route('dashboard.projects.edit', $project->id)->with('success', 'Project created.'); } diff --git a/app/Http/Requests/Project/StoreRequest.php b/app/Http/Requests/Project/StoreRequest.php index 6a6353a5..ea89e600 100644 --- a/app/Http/Requests/Project/StoreRequest.php +++ b/app/Http/Requests/Project/StoreRequest.php @@ -46,6 +46,7 @@ public function rules(): array 'is_national' => ['boolean', 'nullable'], 'file_group' => ['array', 'nullable'], 'file_group.*.file' => ['file', 'nullable'], + 'preview' => ['file', 'nullable'], ]; } } diff --git a/app/Services/ProjectService.php b/app/Services/ProjectService.php index 7e8810bd..3e2525d2 100644 --- a/app/Services/ProjectService.php +++ b/app/Services/ProjectService.php @@ -29,7 +29,6 @@ public function create(array $data): Project|RegionalProject { $data['organization_id'] = auth()->user()->organization_id; $data['status'] = ProjectStatus::draft->value; - $project = $this->createDraftProject($data); if (! empty($data['categories'])) { $project->categories()->attach($data['categories']); @@ -37,6 +36,16 @@ public function create(array $data): Project|RegionalProject if (! empty($data['counties'])) { $project->counties()->attach($data['counties']); } + if (!empty($data['preview'])) + { + $project->addMedia($data['preview'])->toMediaCollection('preview'); + } + if (!empty($data['gallery'])) + { + collect($data['gallery'])->map(function ($image) use ($project) { + $project->addMedia($image)->toMediaCollection('gallery'); + }); + } return $project; } diff --git a/lang/ro.json b/lang/ro.json index 5c90f960..b5218dce 100644 --- a/lang/ro.json +++ b/lang/ro.json @@ -448,7 +448,9 @@ "projects.status.open" : "Deschis", "projects.status.close" : "Închis", "projects.status.starting_soon" : "Incepe in curand", - "projects.status.ending_soon" : "Se incheie in curand" + "projects.status.ending_soon" : "Se incheie in curand", + + "project.labels.preview_image": "Imagine de prezentare" diff --git a/resources/js/Components/form/FileGroup.vue b/resources/js/Components/form/FileGroup.vue index 9781a6a6..d653e186 100644 --- a/resources/js/Components/form/FileGroup.vue +++ b/resources/js/Components/form/FileGroup.vue @@ -1,9 +1,7 @@