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 | * Movie API Resource for transforming movie data. |
||
| 10 | */ |
||
| 11 | class MovieResource 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 | 'imdbid' => $this->imdbid, |
||
|
0 ignored issues
–
show
The property
imdbid does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 23 | 'tmdbid' => $this->tmdbid, |
||
|
0 ignored issues
–
show
The property
tmdbid does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 24 | 'traktid' => $this->traktid, |
||
|
0 ignored issues
–
show
The property
traktid does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 25 | 'title' => $this->title, |
||
|
0 ignored issues
–
show
The property
title does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 26 | 'year' => $this->year, |
||
|
0 ignored issues
–
show
The property
year does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 27 | 'rating' => $this->rating, |
||
|
0 ignored issues
–
show
The property
rating does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 28 | 'rtrating' => $this->rtrating, |
||
|
0 ignored issues
–
show
The property
rtrating does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 29 | 'tagline' => $this->tagline, |
||
|
0 ignored issues
–
show
The property
tagline does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 30 | 'plot' => $this->plot, |
||
|
0 ignored issues
–
show
The property
plot does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 31 | 'genre' => $this->genre, |
||
|
0 ignored issues
–
show
The property
genre does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 32 | 'type' => $this->type, |
||
|
0 ignored issues
–
show
The property
type does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 33 | 'director' => $this->director, |
||
|
0 ignored issues
–
show
The property
director does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 34 | 'actors' => $this->actors, |
||
|
0 ignored issues
–
show
The property
actors does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 35 | 'language' => $this->language, |
||
|
0 ignored issues
–
show
The property
language does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 36 | 'cover' => $this->cover ? true : false, |
||
|
0 ignored issues
–
show
The property
cover does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 37 | 'backdrop' => $this->backdrop ? true : false, |
||
|
0 ignored issues
–
show
The property
backdrop does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 38 | 'trailer' => $this->trailer, |
||
|
0 ignored issues
–
show
The property
trailer does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 39 | 'cover_url' => $this->getCoverUrl(), |
||
| 40 | 'backdrop_url' => $this->getBackdropUrl(), |
||
| 41 | 'imdb_url' => $this->imdbid ? 'https://www.imdb.com/title/tt'.$this->imdbid.'/' : null, |
||
| 42 | 'created_at' => $this->created_at?->toIso8601String(), |
||
|
0 ignored issues
–
show
The property
created_at does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 43 | 'updated_at' => $this->updated_at?->toIso8601String(), |
||
|
0 ignored issues
–
show
The property
updated_at does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 44 | ]; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Get the cover image URL. |
||
| 49 | */ |
||
| 50 | protected function getCoverUrl(): ?string |
||
| 51 | { |
||
| 52 | if (! $this->cover || ! $this->imdbid) { |
||
|
0 ignored issues
–
show
The property
cover does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
The property
imdbid does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 53 | return null; |
||
| 54 | } |
||
| 55 | |||
| 56 | return url('/covers/movies/'.$this->imdbid.'-cover.jpg'); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Get the backdrop image URL. |
||
| 61 | */ |
||
| 62 | protected function getBackdropUrl(): ?string |
||
| 63 | { |
||
| 64 | if (! $this->backdrop || ! $this->imdbid) { |
||
|
0 ignored issues
–
show
The property
imdbid does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
The property
backdrop does not exist on App\Http\Resources\MovieResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 65 | return null; |
||
| 66 | } |
||
| 67 | |||
| 68 | return url('/covers/movies/'.$this->imdbid.'-backdrop.jpg'); |
||
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 72 |