Releases: BinarCode/laravel-restify
Releases · BinarCode/laravel-restify
3.12.0
Added
- Match by datetime
class PostRepository extends Repository
{
public static $match = [
'published_at' => RestifySearchable::MATCH_DATETIME,
];
}
Request:
GET: /restify-api/posts?published_at=2020-12-01
- Match by array
class PostRepository extends Repository
{
public static $match = [
'published_at' => RestifySearchable::MATCH_ARRAY,
];
}
Request:
GET: /restify-api/posts?id=1,2,3
This will be converted to:
->whereIn('id', [1, 2, 3])
- Negate a match
GET: /restify-api/posts?-id=1,2,3
This will return all posts where doesn't have the id
in the [1,2,3]
list.
You can apply -
(negation) for every match:
GET: /restify-api/posts?-title="Some title"
3.11.0
Added
This is very wanted feature, for a long time.
- Actions, an action performed to a bunch of models, or to a single model. Check it out
Before:
After:
3.10.0
Added
Bulk store
POST: restify-api/posts/bulk
Payload:
[ { "title": "Post title 1"}, { "title": "Post title 2"} ]
Bulk udpate
This is as well post. Just because using "POST" you can pass form data:
POST: restify-api/posts/bulk/update
Payload:
[ { "id":1, "title": "Post title 1"}, { "id": 2, "title": "Post title 2"} ]
3.9.0
3.8.0
Added
- RestResponse static
index
method, so you can return the same format for a custom paginator.
$paginator = User::query()->paginate(5);
$response = Binaryk\LaravelRestify\Controllers\RestResponse::index(
$paginator
);
Changed
- Signature of the
resolveIndexMainMeta
method, now it accept thepaginatorMeta
information:
public function resolveIndexMainMeta(RestifyRequest $request, Collection $items, array $paginationMeta): array
3.7.0
Index main meta
You can also override the main meta
object for the index, not the one for per item:
public function resolveIndexMainMeta(RestifyRequest $request, Collection $items)
{
$default = parent::resolveIndexMeta($request);
return array_merge($default, [
'next_payment_at' => $this->resource->current_payment_at->addMonth(),
]);
}
3.6.0
Added
Ability to setup your own attachers. For example if you want to attach users to a role, and you don't want to use the default attach method. In this case you can override the attach method like this:
// RoleRepository.php
public function attachUsers(RestifyRequest $request, Repository $repository, Model $model)
{
ModelHasRole::create([
'role_id' => $model->id,
'model_type' => User::class,
'model_id' => $request->get('users'),
]);
return $this->response()->created();
}
The URL used for attach will remain the same as for a normal attach:
'restify-api/roles/' . $role->id . '/attach/users'
3.5.1
3.5.0
Added
- Possibility to add custom middleware the repository level:
public static $middlewares = [
PostAbortMiddleware::class,
];
or if you need RestifyRequest you can override the collecting method:
public static function collectMiddlewares(RestifyRequest $request): ?Collection
{
if ($request->isStoreRequest()) {
return collect([PostAbortMiddleware::class]);
}
}
- Adapting profile endpoint to return
attributes
property.