- The
$eagerState
repository property is now private, and it is of typenull|string
because it holds the parent repository that renders it.
High impact:
- Any action permitted unless the Model Policy exists and the method is defined
- PHP8.0 is required
- Laravel 9 is required
- Repository.php:
- static
to
method renamed toroute
$withs
class property was renamed to$with
so it matches the Eloquent default$defaultPerPage
and$defaultRelatablePerPage
has a type ofint
, if you override this make sure you addint
typeeagerState
method was deleted from the repository, there is no need to call it anymore, the repository will be resolved automatically$prefix
property requires astring
typeresolveShowMeta
is not inherited for theresolveIndexMeta
anymore, both methods are now usingpolicyMeta
method, so override thepolicyMeta
instead. This could be simply solved if you replace in all repositoriesresolveShowMeta
withpolicyMeta
.
- static
- Relations that are present into
include
orrelated
will be preloaded, so if you didn't specify a repository to serialize the related relationship, and you're looking for the Eloquent to resolve it, it will not invoke therestify.casts.related
cast anymore, instead it'll load the relationship as it. This has a performance reason under the hood. - Since related relationships will be preloaded, the format of the belongs to will be changed now. If you didn't specify the repository to serialize the
belongsTo
relationship, it'll be serialized as an object, not array anymore:
Before:
"relationships": {
"user": [{
"name": "Foo"
}]
}
Now:
"relationships": {
"user": {
"name": "Foo"
}
}
Low impact:
- Restify.php -
repositoryForKey
renamed torepositoryClassForKey
- The
src/Events/AddedRepositories.php
event was removed because of a conflict with telescope.
- The major deprecation was the
AuthController
deletion, as it wasn't very intuitive and configurable. Intead we developed individual controllers for each auth action, you can release them using therestify:auth
command. See more on the official docs; - Matchable are now only read from query params, not post payloads. So make sure all matchable filters are in query params.
- Actions are not logged if the model doesn't use HasActionLog trait.
- A major breaking change was made around the
storeCallback
,updateCallback
andstoreBulkCallback
. In 5.x the closure was receiving theRestifyRequest $request
instance, however now, it only gets the value (so it's compatible with theshowCallback
orindexCallback
):
field('name')->storeCallback(fn($value) => Str::upper($value)) // $value === $request->input('name')
How to fix:
If you already implemented this callback, you still can use instead the fillCallback
, so simply replace you storeCallback
with fillCallback
:
field('name')->fillCallback(function(RestifyRequest $request) {
if ($request->isStoreRequest()) {
return Str::upper($request->input('name'));
}
});
filters
- explicitarray
returned typegetSearchableFields()
- deprecated, to usesearchables
getMatchByFields()
- deprecated, to usematches
getOrderByFields()
- deprecated, to usesorts
availableFilters
now returns an instance ofFiltersCollection
, so if you overwrite this, make sure to adapt.uriTo
- explicitstring
returned type- The support for relatable via query params was dropped because of security reasons. Now we only maintain the relatable via
BelongsToMany
orHasMany
fields. ie:/posts?parentRepository=users&parentRepositoryId=1
should be now:/users/1/posts
and define the'posts' => HasMany::new('')...
into yourUserRepository
- Repository
index
,show
,store
,update
,destroy
should specify theJsonResponse
return. getRelated
method was dropped - userelated
insteadgetMatchByFields
method was dropped - usematches
insteadgetOrderByFields
method was dropped - usesorts
insteadgetSearchableFields
method was dropped - usesearchables
insteadgetWiths
method was dropped - usewiths
instead
-
uriKey()
-string
returned type -
BooleanFilter
- changed namespace toBinaryk\LaravelRestify\Filters
-
SelectFilter
- changed namespace toBinaryk\LaravelRestify\Filters\SelectFilter
and must implement theoptions
method and return an array. The key should be the value the frontend can send and value would be the label frontend could use to display the select. ie: ['is_active' => 'Is Active'] -
There is no more
class
property for the advanced filters, the frontend should only send theykey
of the filter. -
The
filters
method from the repository should return a list ofAdvancedFilers
. -
The
resolve
method for the advanced filters now requires aAdvancedFilterPayloadDto
instance. -
The
value
argument for the third parameter forAdvancedFilters
will be resolved from theAdvancedFilterPayloadDto@value
method -
Each advanced filter must implement the
rules
method which returns the validation payload for the filter.
- POST
/profile/avatar
was deleted.
- RestController namespace was changed to
Binaryk\LaravelRestify\Http\Controllers
so you should refactor all of yours classes where you have used it (tip: you can usedata()
helper to wrap any response into json withdata
key) Action
base class doesn't extend anymore theRestController
.RestifyHandler
was removed.
- For all related fields (BelongsTo, HasMany etc.) was dropped the argument one, so instead of
BelongsTo::make('user', 'user', UserRepository::class)
you have to use:BelongsTo::make('user', UserRepository::class)
RestifyServiceProviderRegistered
event was removed
- Copy the
database/migrations/create_action_logs_table.php
migration to yours local migrations and runphp artisan migrate
to ensure you can benefit from theaction logs
.
- Dropped support for laravel passport
- Now you have to explicitly define the
allowRestify
method in the model policy, by default Restify don't allow you to use repositories. viewAny
policy isn't used anymore, you can delete it.- The default exception handler is the Laravel one, see
restify.php -> handler
fillCallback
signature has changed- By default it will do not allow you to attach
belongsToMany
andmorphToMany
relationships. You will have to addBelongsToMany
orMorphToMany
field into your repository - All of the
Repository
getter methods should declare the returned type, for instance thefieldsForIndex
method should say that it returns an:array
- Attach endpoint:
"api/restify/users/{$user->id}/attach/roles", [
'roles' => [$role->id],
]
now requires to have a Binaryk\LaravelRestify\Fields\BelongsToMany
or Binaryk\LaravelRestify\Fields\MorphToMany
field to be defined in the repository.
-
Field method
append
renamed tovalue
. -
The relations from the Repository
$related
, which are resolved via aIlluminate\Database\Eloquent\Relations\Relation
orIlluminate\Database\Eloquent\Builder
will do not have anymore theattributes
property in the relations. To support this format, you can configure a custom Cast onrestify.php
, see theBinaryk\LaravelRestify\Tests\Fixtures\Post\RelatedCastWithAttributes::class
, it returns the old 3.x format.