Skip to content

Commit

Permalink
fix: worng website selected
Browse files Browse the repository at this point in the history
  • Loading branch information
itzArtha committed Dec 11, 2024
1 parent f57ba12 commit 10bf3f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
namespace App\Actions\Portfolio\Announcement\UI;

use App\Enums\Portfolio\Announcement\AnnouncementStatusEnum;
use App\Models\Announcement;
use App\Models\Portfolio\PortfolioWebsite;
use Illuminate\Database\Eloquent\Collection;
use Lorisleiva\Actions\Concerns\AsAction;
use Spatie\QueryBuilder\QueryBuilder;

class GetActiveAnnouncement
{
use AsAction;

public function handle(PortfolioWebsite $portfolioWebsite): Collection
{
return $portfolioWebsite->announcements()
$queryBuilder = QueryBuilder::for(Announcement::class);

return $queryBuilder
->where('portfolio_website_id', $portfolioWebsite->id)
->where('status', AnnouncementStatusEnum::ACTIVE->value)
->get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ class ShowCompiledAnnouncement

public function handle(PortfolioWebsite $portfolioWebsite, ?string $targetPage, string $targetUser): ?Announcement
{
$announcements = GetActiveAnnouncement::run($portfolioWebsite);
$announcements = GetActiveAnnouncement::run();

foreach ($announcements as $announcement) {
$selectedAnnouncement = $announcement
->where(function ($query) use ($targetPage) {
->where(function ($query) use ($targetPage, $portfolioWebsite) {
$query->where('status', AnnouncementStatusEnum::ACTIVE->value)
->where('portfolio_website_id', $portfolioWebsite->id)
->where(function ($subQuery) use ($targetPage) {
$subQuery->whereRaw("
EXISTS (
Expand Down

0 comments on commit 10bf3f7

Please sign in to comment.