/** * @param PrepareApiAttributes $event */ public function addAttributes(PrepareApiAttributes $event) { if ($event->isSerializer(UserSerializer::class)) { $canSuspend = $event->actor->can('suspend', $event->model); if ($canSuspend) { $event->attributes['suspendUntil'] = $event->formatDate($event->model->suspend_until); } $event->attributes['canSuspend'] = $canSuspend; } }