-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating route to get tags by namespace
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
Modules/Tag/Http/Controllers/Api/TagByNamespaceController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Modules\Tag\Http\Controllers\Api; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Routing\Controller; | ||
use Modules\Tag\Repositories\TagRepository; | ||
use Modules\Tag\Transformers\TagTransformer; | ||
|
||
class TagByNamespaceController extends Controller | ||
{ | ||
/** | ||
* @var TagRepository | ||
*/ | ||
private $tag; | ||
|
||
public function __construct(TagRepository $tag) | ||
{ | ||
$this->tag = $tag; | ||
} | ||
|
||
public function __invoke(Request $request) | ||
{ | ||
$availableTags = $this->tag->allForNamespace($request->get('namespace')); | ||
|
||
return response()->json(TagTransformer::collection($availableTags)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
use Illuminate\Routing\Router; | ||
|
||
/** @var Router $router */ | ||
$router->get('tags/namespace', [ | ||
'as' => 'api.tag.tag.by-namespace', | ||
'uses' => 'TagByNamespaceController', | ||
'middleware' => 'token-can:tag.tags.index', | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters