Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nested entities transformer map in parent transformer apiary helper factory fix for transformer setter auth transformer fix
- Loading branch information
Showing
10 changed files
with
189 additions
and
20 deletions.
There are no files selected for viewing
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
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,31 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: ivanmatveev | ||
* Date: 21.08.15 | ||
* Time: 17:15 | ||
*/ | ||
|
||
namespace App\Http\Transformers; | ||
|
||
use App\Models\Tag; | ||
|
||
class ArticleTagTransformer extends EloquentModelTransformer | ||
{ | ||
public $addSelfKey = false; | ||
|
||
/** | ||
* @param $collection | ||
* @return mixed | ||
*/ | ||
public function transformCollection($collection) | ||
{ | ||
/** @var Tag[] $collection */ | ||
foreach ($collection as $item) { | ||
$item->addHidden(['tag_id','pivot']); | ||
} | ||
|
||
return parent::transformCollection($collection); | ||
} | ||
|
||
} |
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
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
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
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
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
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
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,70 @@ | ||
# Group Article Tags | ||
Tags are generic mechanism of tagging particular article and find articles having one and the same tag. | ||
|
||
## Tag Entity [/tags] | ||
|
||
### Create tag entity [POST] | ||
|
||
#### Restrictions | ||
* Allowed - [admin] | ||
|
||
+ Request | ||
+ Body | ||
|
||
{!! | ||
$factory->get(\App\Models\Tag::class) | ||
->hide(['_self']) | ||
->json() | ||
!!} | ||
|
||
+ Request | ||
+ Body | ||
|
||
{!! | ||
$factory->get(\App\Models\Tag::class) | ||
->showOnly(['_self']) | ||
->json() | ||
!!} | ||
|
||
+ Response 201 | ||
|
||
## Exiting Tag Entity Actions [/tags/{tagId}] | ||
|
||
+ Parameters | ||
+ tagId (required, uuid, `{!! $faker->uuid !!}`) ... Unique `id` or `tag` of the tag to perform action with. | ||
|
||
|
||
### Retrieve a tag [GET] | ||
|
||
#### Restrictions | ||
* Allowed - [admin] | ||
+ Response 200 (application/json) | ||
|
||
+ Body | ||
|
||
{!! $factory->json(\App\Models\Tag::class) !!} | ||
|
||
### Update the tag [PATCH] | ||
|
||
#### Restrictions | ||
* Allowed - [admin] | ||
|
||
+ Request | ||
+ Body | ||
|
||
{!! | ||
$factory->get(\App\Models\Tag::class) | ||
->hide(['_self']) | ||
->showOnly(['tag']) | ||
->json() | ||
!!} | ||
|
||
|
||
+ Response 204 | ||
|
||
|
||
### Delete the tag [DELETE] | ||
#### Restrictions | ||
* Allowed - [admin] | ||
|
||
+ Response 204 |
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