$this->id, 'email' => $this->email, 'surname' => $this->lastname, 'firstname' => $this->firstname, 'password' => $this->password, 'activated' => $this->status, 'role' => ($this->role === 1) ? "TOTAL" : "USER", 'authorizedFolders' => json_encode($this->directories->each(function (Directory $directory) use ($request) { return (new DirectoryResource($directory))->toArray($request); })), 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, ]; } }