-
-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
I have a model that implements both HasAllowedFilters
and HasAllowedSorts
.
I also have a Transformer for that model which returns objects that have their own properties.
When I open Scramble API docs there is no way to specify a filter or sort, nor can I see the proper response example that matches the Trasnformer.
How to reproduce the bug
Create a modal an add at the end of it HasAllowedFilters, HasAllowedSorts
Then add these two methods in your model class
public static function getAllowedFilters(): array
{
return [
'name'
];
}
public static function getAllowedSorts(): array
{
return [
'name'
];
}
Open up the Scramble API docs and you will see that there is no way to specify the filter nor sort.
For the second issue, create a transformer and just specify an one-to-many or many-to-many relationship and the response in the Scramble API docs will not mirror the transformer.
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'slug' => $this->slug,
'description' => $this->description,
'price' => $this->price,
'tags' => $this->tags->pluck('name'),
'category' => $this->category->name,
];
}
Package Version
3.4
PHP Version
8.2
Laravel Version
12.0
Which operating systems does with happen with?
macOS
Notes
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working