*/ public function toArray(Request $request): array { return [ 'id' => $this->public_id, 'name' => $this->name, 'username' => $this->username, 'email' => $this->email, 'two_factor_enabled' => $this->two_factor_enabled, 'roles' => $this->getRoleNames(), 'permissions' => $this->getAllPermissions()->pluck('name'), 'created_at' => $this->created_at, 'can_edit' => $request->user()?->can('users.update') ?? false, 'can_delete' => $request->user()?->can('users.delete') && $request->user()->id !== $this->id, ]; } }