Skip to content

Commit 4cf5507

Browse files
simonhampclaude
andcommitted
Add Wall of Love edit profile, upgrade forms to Flux, remove old views
Allow Wall of Love users to edit their photo and company name without re-approval. Add nav item for eligible users, upgrade both Showcase and Wall of Love forms to Flux UI components, and remove old unused controller-based views and the WallOfLoveBanner component. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 219c835 commit 4cf5507

28 files changed

+384
-2654
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\Livewire\Customer\WallOfLove;
4+
5+
use App\Models\WallOfLoveSubmission;
6+
use Livewire\Attributes\Layout;
7+
use Livewire\Attributes\Title;
8+
use Livewire\Component;
9+
10+
#[Layout('components.layouts.dashboard')]
11+
#[Title('Edit Your Listing')]
12+
class Edit extends Component
13+
{
14+
public WallOfLoveSubmission $wallOfLoveSubmission;
15+
16+
public function mount(WallOfLoveSubmission $wallOfLoveSubmission): void
17+
{
18+
abort_if($wallOfLoveSubmission->user_id !== auth()->id(), 403);
19+
}
20+
}

app/Livewire/WallOfLoveBanner.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

app/Livewire/WallOfLoveSubmissionForm.php

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,76 @@ class WallOfLoveSubmissionForm extends Component
1010
{
1111
use WithFileUploads;
1212

13+
public ?WallOfLoveSubmission $submission = null;
14+
15+
public bool $isEditing = false;
16+
1317
public $name = '';
1418

1519
public $company = '';
1620

1721
public $photo;
1822

23+
public ?string $existingPhoto = null;
24+
1925
public $url = '';
2026

2127
public $testimonial = '';
2228

23-
protected $rules = [
24-
'name' => 'required|string|max:255',
25-
'company' => 'nullable|string|max:255',
26-
'photo' => 'nullable|image|max:2048', // 2MB max
27-
'url' => 'nullable|url|max:255',
28-
'testimonial' => 'nullable|string|max:1000',
29-
];
29+
public function mount(?WallOfLoveSubmission $submission = null): void
30+
{
31+
if ($submission && $submission->exists && $submission->user_id === auth()->id()) {
32+
$this->submission = $submission;
33+
$this->isEditing = true;
34+
$this->name = $submission->name;
35+
$this->company = $submission->company ?? '';
36+
$this->existingPhoto = $submission->photo_path;
37+
$this->url = $submission->url ?? '';
38+
$this->testimonial = $submission->testimonial ?? '';
39+
} else {
40+
// Pre-fill name if user has a name
41+
$this->name = auth()->user()->name ?? '';
42+
}
43+
}
3044

31-
public function mount()
45+
public function rules(): array
3246
{
33-
// Pre-fill name if user has a name
34-
$this->name = auth()->user()->name ?? '';
47+
if ($this->isEditing) {
48+
return [
49+
'company' => 'nullable|string|max:255',
50+
'photo' => 'nullable|image|max:2048',
51+
];
52+
}
53+
54+
return [
55+
'name' => 'required|string|max:255',
56+
'company' => 'nullable|string|max:255',
57+
'photo' => 'nullable|image|max:2048',
58+
'url' => 'nullable|url|max:255',
59+
'testimonial' => 'nullable|string|max:1000',
60+
];
3561
}
3662

37-
public function submit()
63+
public function submit(): mixed
3864
{
3965
$this->validate();
4066

67+
if ($this->isEditing && $this->submission) {
68+
$data = [
69+
'company' => $this->company ?: null,
70+
];
71+
72+
if ($this->photo) {
73+
$data['photo_path'] = $this->photo->store('wall-of-love-photos', 'public');
74+
} elseif ($this->existingPhoto === null) {
75+
$data['photo_path'] = null;
76+
}
77+
78+
$this->submission->update($data);
79+
80+
return to_route('dashboard')->with('success', 'Your listing has been updated.');
81+
}
82+
4183
$photoPath = null;
4284
if ($this->photo) {
4385
$photoPath = $this->photo->store('wall-of-love-photos', 'public');
@@ -55,6 +97,11 @@ public function submit()
5597
return to_route('dashboard')->with('success', 'Thank you! Your submission has been received and is awaiting review.');
5698
}
5799

100+
public function removeExistingPhoto(): void
101+
{
102+
$this->existingPhoto = null;
103+
}
104+
58105
public function render()
59106
{
60107
return view('livewire.wall-of-love-submission-form');

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/views/components/dashboard-menu.blade.php

Lines changed: 0 additions & 62 deletions
This file was deleted.

resources/views/components/layouts/dashboard.blade.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ class="min-h-screen bg-white font-poppins antialiased dark:bg-zinc-900 dark:text
115115
<flux:sidebar.item href="{{ route('customer.showcase.index') }}" :current="request()->routeIs('customer.showcase.*')">
116116
Showcase
117117
</flux:sidebar.item>
118+
@if(auth()->user()->licenses()->where('created_at', '<', '2025-06-01')->exists())
119+
@php
120+
$wallOfLoveSubmission = auth()->user()->wallOfLoveSubmissions()->first();
121+
$wallOfLoveUrl = $wallOfLoveSubmission
122+
? route('customer.wall-of-love.edit', $wallOfLoveSubmission)
123+
: route('customer.wall-of-love.create');
124+
@endphp
125+
<flux:sidebar.item href="{{ $wallOfLoveUrl }}" :current="request()->routeIs('customer.wall-of-love.*')">
126+
Wall of Love
127+
</flux:sidebar.item>
128+
@endif
118129
<flux:sidebar.item href="https://discord.gg/nativephp" target="_blank">
119130
Discord
120131
</flux:sidebar.item>

0 commit comments

Comments
 (0)