Skip to content

Commit

Permalink
add forceAppend as attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
d8vjork committed Sep 19, 2023
1 parent 4eb6143 commit 1001b60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Attributes/ForceAppendAttribute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace OpenSoutheners\LaravelApiable\Attributes;

use Attribute;

#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class ForceAppendAttribute
{
public function __construct(public string|array $type, public string|array $attributes)
{
//
}
}
2 changes: 2 additions & 0 deletions src/Http/Concerns/ResolvesFromRouteAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use OpenSoutheners\LaravelApiable\Attributes\ApplyDefaultSort;
use OpenSoutheners\LaravelApiable\Attributes\FieldsQueryParam;
use OpenSoutheners\LaravelApiable\Attributes\FilterQueryParam;
use OpenSoutheners\LaravelApiable\Attributes\ForceAppendAttribute;
use OpenSoutheners\LaravelApiable\Attributes\IncludeQueryParam;
use OpenSoutheners\LaravelApiable\Attributes\QueryParam;
use OpenSoutheners\LaravelApiable\Attributes\SearchFilterQueryParam;
Expand Down Expand Up @@ -64,6 +65,7 @@ protected function resolveAttributesFrom($reflected)
$attributeInstance = $allowedQueryParam->newInstance();

match (true) {
$attributeInstance instanceof ForceAppendAttribute => $this->forceAppend($attributeInstance->type, $attributeInstance->attributes),
$attributeInstance instanceof SearchQueryParam => $this->allowSearch($attributeInstance->allowSearch),
$attributeInstance instanceof SearchFilterQueryParam => $this->allowSearchFilter($attributeInstance->attribute, $attributeInstance->values),
$attributeInstance instanceof FilterQueryParam => $this->allowFilter($attributeInstance->attribute, $attributeInstance->type, $attributeInstance->values),
Expand Down

0 comments on commit 1001b60

Please sign in to comment.