-
Notifications
You must be signed in to change notification settings - Fork 59
Closed
Description
Hello,
i have created a media relation
`<?php
namespace App\Restify\Actions\User;
use App\Models\User;
use Binaryk\LaravelRestify\Actions\Action;
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
class AttachUserAvatarRestifyAction extends Action
{
public function handle(RestifyRequest $request, User $user)
{
if ($request->hasFile('avatar')) {
if ($user->avatar) {
$user->avatar->delete();
}
$user->addMediaFromRequest('avatar')->toMediaCollection('avatars');
return $user->avatar?->getUrl();
}
}
}
`
and on UserRepository
field('avatar', fn () => $this->model()->avatar?->getUrl())->rules(['image'])->action(new AttachUserAvatarRestifyAction)
So all is good but i think the action trigger after the value of this field returns the old data returned.
Thanks
Metadata
Metadata
Assignees
Labels
No labels