Skip to content

Commit

Permalink
Update ContentIndexResource.php (#64)
Browse files Browse the repository at this point in the history
* Update ContentIndexResource.php

* Update ContentIndexResource.php

* Update LibraryResource.php
  • Loading branch information
qunabu authored Jan 20, 2022
1 parent 907174e commit 6cba265
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/Http/Resources/ContentIndexResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,31 @@
namespace EscolaLms\HeadlessH5P\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use EscolaLms\HeadlessH5P\Models\H5PLibrary;
use EscolaLms\HeadlessH5P\Http\Resources\LibraryResource;

class ContentIndexResource extends JsonResource
{
public function toArray($request): array
{
$lib = H5PLibrary::find($this->library_id);

return [
'id' => $this->id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'user_id' => $this->user_id,
'title' => $this->title,
'library_id' => $this->library_id,
'library' => isset($lib) ? (new LibraryResource($lib))->toArray() : null,
'parameters' => $this->parameters,
'params' => $this->params,
'metadata' => $this->metadata,
'slug' => $this->slug,
'filtered' => $this->filtered,
'disable' => $this->disable,
'embed_type' => $this->embed_type,
'nonce' => $this->nonce,
];
}
}
2 changes: 1 addition & 1 deletion src/Http/Resources/LibraryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct(H5PLibrary $library)
$this->resource = $library;
}

public function toArray($request): array
public function toArray($request = null): array
{
return [
'id' => $this->id,
Expand Down

0 comments on commit 6cba265

Please sign in to comment.