The fastest way to make a powerful JSON:API compatible Rest API with Laravel.
MIT License
Bot releases are hidden (Show)
Published by binaryk over 3 years ago
Published by binaryk over 3 years ago
key
for simple filtersPublished by binaryk over 3 years ago
patch
verb will now validate / authorize and update by attributetitle
, description
and column
so you can easily customize it. The full definition of an AdvancedFilter's looks like:
array:8 [
"type" => "multiselect"
"advanced" => true
"title" => "Status filter"
"description" => "Short description"
"column" => "status"
"key" => "status-filter"
"rules" => array:1 [
"status" => array:1 [
0 => "required"
]
]
"options" => array:1 [
0 => array:2 [
"label" => "Draft"
"property" => "draft"
]
]
]
Binaryk\LaravelRestify\Filters\MultiSelectFilter
Published by binaryk over 3 years ago
data
helper typehintPublished by binaryk over 3 years ago
data
helper now accept status.Published by binaryk over 3 years ago
AdvancedFilter
.Published by binaryk over 3 years ago
filters
link to the index links
listPublished by binaryk over 3 years ago
Published by binaryk over 3 years ago
public static function matches(): array
{
return [
'name' => MatchFilter::make()
->setType(RestifySearchable::MATCH_TEXT)
->partial(),
'code' => MatchFilter::make()
->setType(RestifySearchable::MATCH_TEXT)
->strict(),
So now if your frontend will call:
/users?name=John
the search will return back even users with a name like: John Doe
If you are using ->strict()
modifier, which is by default for all matches, then the API will search only for the name John
.
Published by binaryk over 3 years ago
// PostRepository
related() {
'user' => BelongsTo::make('user', 'user', UserRepository::class)->searchable([
'users.name'
])
}
So now your search will consider the users.name
as well in a orWhere
query:
?search=John Doe
this will return you back all your posts where the belongs to user name has %John Doe%
name
column, now it's dynamical.Published by binaryk over 3 years ago
related() : array
{
return [ 'owner' => fn() => 'John Doe'; ];
}
Published by binaryk over 3 years ago
Image
field now can use the ->default('image.png')
, so if the image is not on the disk, it will fallback into it.Published by binaryk over 3 years ago
Published by binaryk over 3 years ago
// Repository:
$match = [
'created_at' => RestifySearchable::MATCH_DATETIME_INTERVAL,
];
Query:
// Use isoString format
GET: /posts?created_at=created_at=2020-12-16T09:48:52.480645Z,2021-02-16T09:48:52.481004Z
This will filter by this interval.
You can also negate this by using -
before the column name: -created_at=
.
Published by binaryk over 3 years ago
// PostRepository
public static function sorts(): array
{
return [
'users.attributes.name' => SortableFilter::make()->setColumn('users.name')->usingBelongsTo(
BelongsTo::make('user', 'user', UserRepository::class),
)
];
}
And frontend can filter your posts by users.name
using:
api/restify/posts?sort=users.attributes.name
.
Published by binaryk over 3 years ago
php artisan restify:setup
command issue with the config publishing.Published by binaryk almost 4 years ago
BelongsToMany
, MorphToMany
fields now you can specify validations rules using:BelongsToMany::make('roles', 'roles', RolesRepository::class)->validationCallback(fn(Request $request) => ....))
->unique()
to BelongsToMany
kind fields, so you can validate unicity of your pivot table entries.$withs
property for repositories when force eager loading.Published by binaryk almost 4 years ago
ArticleRepository
for example, Restify will guess the model App\Models\Article
so you don't have to define the model
static property.Published by binaryk almost 4 years ago
data
helperPublished by binaryk almost 4 years ago