-
app/Http/Controllers/Discovery/Community/LinkApproval.php
Open in GitHubuse App\Actions\ApproveLinkAction; use App\Actions\RejectLinkAction; use App\Models\Link; class LinkApproval { public function approve(Link $link, ApproveLinkAction $approveLinkAction) { $approveLinkAction->execute($link); return view('front.links.approved'); } public function reject(Link $link, RejectLinkAction $rejectLinkAction) { $rejectLinkAction->execute($link); return view('front.links.rejected'); } }
-
app/Actions/ApproveLinkAction.php
Open in GitHubuse App\Mail\LinkApprovedMail; use App\Models\Link; use Illuminate\Support\Facades\Mail; use Spatie\ResponseCache\Facades\ResponseCache; class ApproveLinkAction { public function execute(Link $link): Link { if ($link->isApproved()) { return $link; } Mail::to($link->user->email)->queue(new LinkApprovedMail($link)); $link->update([ 'publish_date' => now(), 'status' => Link::STATUS_APPROVED, ]); ResponseCache::clear(); return $link; } }