@@ -49,6 +49,48 @@ public static function form(Form $form): Form
4949 ->maxLength (1000 )
5050 ->rows (4 ),
5151 ]),
52+
53+ Forms \Components \Section::make ('Status & Promotion ' )
54+ ->schema ([
55+ Forms \Components \Toggle::make ('is_approved ' )
56+ ->label ('Approved ' )
57+ ->helperText ('Approved submissions appear on the Wall of Love. ' )
58+ ->formatStateUsing (fn (?WallOfLoveSubmission $ record ) => $ record ?->isApproved() ?? false )
59+ ->dehydrated (false )
60+ ->afterStateUpdated (function (bool $ state , ?WallOfLoveSubmission $ record ) {
61+ if (! $ record ) {
62+ return ;
63+ }
64+
65+ if ($ state ) {
66+ $ record ->update ([
67+ 'approved_at ' => now (),
68+ 'approved_by ' => auth ()->id (),
69+ ]);
70+ } else {
71+ $ record ->update ([
72+ 'approved_at ' => null ,
73+ 'approved_by ' => null ,
74+ 'promoted ' => false ,
75+ 'promoted_testimonial ' => null ,
76+ ]);
77+ }
78+ })
79+ ->live (),
80+
81+ Forms \Components \Toggle::make ('promoted ' )
82+ ->label ('Promoted to Homepage ' )
83+ ->helperText ('Promoted submissions appear in the feedback section on the homepage. ' )
84+ ->visible (fn (Forms \Get $ get ) => $ get ('is_approved ' ))
85+ ->live (),
86+
87+ Forms \Components \Textarea::make ('promoted_testimonial ' )
88+ ->label ('Promoted Testimonial (optional override) ' )
89+ ->helperText ('Leave empty to use the original testimonial, or enter a clipped version for the homepage. ' )
90+ ->rows (4 )
91+ ->visible (fn (Forms \Get $ get ) => $ get ('is_approved ' ) && $ get ('promoted ' )),
92+ ])
93+ ->columns (1 ),
5294 ]);
5395 }
5496
@@ -84,6 +126,15 @@ public static function table(Table $table): Table
84126 ->falseColor ('warning ' )
85127 ->sortable (),
86128
129+ Tables \Columns \IconColumn::make ('promoted ' )
130+ ->label ('Promoted ' )
131+ ->boolean ()
132+ ->trueIcon ('heroicon-o-star ' )
133+ ->falseIcon ('heroicon-o-star ' )
134+ ->trueColor ('warning ' )
135+ ->falseColor ('gray ' )
136+ ->sortable (),
137+
87138 Tables \Columns \TextColumn::make ('approvedBy.name ' )
88139 ->label ('Approved By ' )
89140 ->toggleable (),
@@ -104,6 +155,12 @@ public static function table(Table $table): Table
104155 true: fn (Builder $ query ) => $ query ->whereNotNull ('approved_at ' ),
105156 false: fn (Builder $ query ) => $ query ->whereNull ('approved_at ' ),
106157 ),
158+
159+ Tables \Filters \TernaryFilter::make ('promoted ' )
160+ ->label ('Promoted ' )
161+ ->placeholder ('All ' )
162+ ->trueLabel ('Promoted ' )
163+ ->falseLabel ('Not Promoted ' ),
107164 ])
108165 ->actions ([
109166 Tables \Actions \Action::make ('approve ' )
@@ -130,6 +187,33 @@ public static function table(Table $table): Table
130187 ->modalHeading ('Unapprove Submission ' )
131188 ->modalDescription ('Are you sure you want to unapprove this submission? ' ),
132189
190+ Tables \Actions \Action::make ('promote ' )
191+ ->icon ('heroicon-o-star ' )
192+ ->color ('warning ' )
193+ ->visible (fn (WallOfLoveSubmission $ record ) => $ record ->isApproved () && ! $ record ->isPromoted ())
194+ ->form ([
195+ Forms \Components \Textarea::make ('promoted_testimonial ' )
196+ ->label ('Testimonial Text (optional override) ' )
197+ ->helperText ('Leave empty to use the original testimonial, or enter a clipped version. ' )
198+ ->rows (4 )
199+ ->default (fn (WallOfLoveSubmission $ record ) => $ record ->testimonial ),
200+ ])
201+ ->action (fn (WallOfLoveSubmission $ record , array $ data ) => $ record ->update ([
202+ 'promoted ' => true ,
203+ 'promoted_testimonial ' => $ data ['promoted_testimonial ' ] !== $ record ->testimonial ? $ data ['promoted_testimonial ' ] : null ,
204+ ]))
205+ ->modalHeading ('Promote to Homepage ' )
206+ ->modalDescription ('This will display this testimonial in the feedback section on the homepage. ' ),
207+
208+ Tables \Actions \Action::make ('unpromote ' )
209+ ->icon ('heroicon-o-x-mark ' )
210+ ->color ('gray ' )
211+ ->visible (fn (WallOfLoveSubmission $ record ) => $ record ->isPromoted ())
212+ ->action (fn (WallOfLoveSubmission $ record ) => $ record ->update (['promoted ' => false ]))
213+ ->requiresConfirmation ()
214+ ->modalHeading ('Remove from Homepage ' )
215+ ->modalDescription ('This will remove this testimonial from the homepage feedback section. ' ),
216+
133217 Tables \Actions \EditAction::make (),
134218 Tables \Actions \DeleteAction::make (),
135219 ])
0 commit comments