Skip to content
This repository was archived by the owner on Aug 5, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Http/Controllers/Api/CampaignsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Sendportal\Base\Http\Controllers\Api;

use Exception;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
use Illuminate\Support\Arr;
use Sendportal\Base\Facades\Sendportal;
Expand Down Expand Up @@ -73,10 +74,16 @@ public function show(int $id): CampaignResource
/**
* @throws Exception
*/
public function showByName(string $name): CampaignResource
public function showByName(string $name): CampaignResource|JsonResponse
{
$workspaceId = Sendportal::currentWorkspaceId();
return new CampaignResource($this->campaigns->findBy($workspaceId, 'name', $name));

$campaign = $this->campaigns->findBy($workspaceId, 'name', $name);
if (!$campaign) {
return new JsonResponse(['message' => 'Campaign not found'], 404);
}

return new CampaignResource($campaign);
}

/**
Expand Down
10 changes: 8 additions & 2 deletions src/Http/Controllers/Api/TagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Exception;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
use Illuminate\Http\Response;
use Sendportal\Base\Facades\Sendportal;
Expand Down Expand Up @@ -73,10 +74,15 @@ public function show(int $id): TagResource
/**
* @throws BindingResolutionException
*/
public function showByName(string $name): TagResource
public function showByName(string $name): TagResource|JsonResponse
{
$workspaceId = Sendportal::currentWorkspaceId();
return new TagResource($this->tags->findBy($workspaceId, 'name', $name));
$tag = $this->tags->findBy($workspaceId, 'name', $name);
if (!$tag) {
return new JsonResponse(['message' => 'Tag not found'], 404);
}

return new TagResource($tag);
}

/**
Expand Down