Releases: BinarCode/laravel-restify
Releases · BinarCode/laravel-restify
4.6.3
4.6.2
4.6.1
4.6.0
4.5.4
4.5.3
4.5.2
4.5.1
4.5.0
Added
- Sorting by
belongsTorelationship:
Sometimes you may need to sort by a belongsTo relationship. This become a breeze with Restify. Firstly you have to
instruct your sort to use a relationship:
// PostRepository
use Binaryk\LaravelRestify\Fields\BelongsTo;
use Binaryk\LaravelRestify\Filters\SortableFilter;
public static function sorts(): array
{
return [
'users.name' => SortableFilter::make()
->setColumn('users.name')
->usingBelongsTo(
BelongsTo::make('user', 'user', UserRepository::class),
)
];
}Make sure that the column is fully qualified (include the table name).
The request could look like:
GET: /api/restify/posts?sort=-users.nameThis will return all posts, sorted descending by users name.
4.4.0
Added
-
Support for
integercolumn type for theartisan restify:stubcommand. -
Support for managing related entities via Eager fields. For example, if you want to have in relationships an
BelongsTofield:
//PostRepository.php
public static function getRelated()
{
return [
'owner' => BelongsTo::make('owner', 'owner', UserRepository::class),
];
}
Then you can get it via related as usual:
/api/restify/posts?related=owner
And the returned object in the relationships will be formatted using UserRepository fields, so you can attach policies and permissions for specific fields in the repository itself.