NNTmux /
newznab-tmux
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Http\Resources; |
||
| 4 | |||
| 5 | use Illuminate\Http\Request; |
||
| 6 | use Illuminate\Http\Resources\Json\JsonResource; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Book API Resource for transforming book data. |
||
| 10 | */ |
||
| 11 | class BookResource extends JsonResource |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * Transform the resource into an array. |
||
| 15 | * |
||
| 16 | * @return array<string, mixed> |
||
| 17 | */ |
||
| 18 | public function toArray(Request $request): array |
||
| 19 | { |
||
| 20 | return [ |
||
| 21 | 'id' => $this->id, |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 22 | 'title' => $this->title, |
||
|
0 ignored issues
–
show
The property
title does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 23 | 'author' => $this->author, |
||
|
0 ignored issues
–
show
The property
author does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 24 | 'asin' => $this->asin, |
||
|
0 ignored issues
–
show
The property
asin does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 25 | 'isbn' => $this->isbn, |
||
|
0 ignored issues
–
show
The property
isbn does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 26 | 'ean' => $this->ean, |
||
|
0 ignored issues
–
show
The property
ean does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 27 | 'url' => $this->url, |
||
|
0 ignored issues
–
show
The property
url does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 28 | 'salesrank' => $this->salesrank, |
||
|
0 ignored issues
–
show
The property
salesrank does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 29 | 'publisher' => $this->publisher, |
||
|
0 ignored issues
–
show
The property
publisher does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 30 | 'publishdate' => $this->publishdate, |
||
|
0 ignored issues
–
show
The property
publishdate does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 31 | 'pages' => $this->pages, |
||
|
0 ignored issues
–
show
The property
pages does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 32 | 'overview' => $this->overview, |
||
|
0 ignored issues
–
show
The property
overview does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 33 | 'genre' => $this->genre, |
||
|
0 ignored issues
–
show
The property
genre does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 34 | 'cover' => $this->cover ? true : false, |
||
|
0 ignored issues
–
show
The property
cover does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 35 | 'cover_url' => $this->getCoverUrl(), |
||
| 36 | 'created_at' => $this->created_at?->toIso8601String(), |
||
|
0 ignored issues
–
show
The property
created_at does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 37 | 'updated_at' => $this->updated_at?->toIso8601String(), |
||
|
0 ignored issues
–
show
The property
updated_at does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 38 | ]; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Get the cover image URL. |
||
| 43 | */ |
||
| 44 | protected function getCoverUrl(): ?string |
||
| 45 | { |
||
| 46 | if (! $this->cover) { |
||
|
0 ignored issues
–
show
The property
cover does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 47 | return null; |
||
| 48 | } |
||
| 49 | |||
| 50 | $coverPath = storage_path('covers/book/'.$this->id.'.jpg'); |
||
|
0 ignored issues
–
show
The property
id does not exist on App\Http\Resources\BookResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 51 | if (file_exists($coverPath)) { |
||
| 52 | return url('/covers/book/'.$this->id.'.jpg'); |
||
| 53 | } |
||
| 54 | |||
| 55 | return null; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | |||
| 59 |