Created
July 8, 2026 16:38
-
-
Save pazteddy/47a09f8d2e8fdc9459ea25d8bdd99d41 to your computer and use it in GitHub Desktop.
Recurso para películas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class MovieResource extends JsonResource | |
| { | |
| public function toArray(Request $request): array | |
| { | |
| return [ | |
| 'id' => $this->id, | |
| 'title' => $this->title, | |
| 'slug' => $this->slug, | |
| 'synopsis' => $this->synopsis, | |
| 'year' => $this->year, | |
| 'rating' => $this->rating, | |
| 'director' => $this->director, | |
| 'duration' => $this->duration, | |
| 'poster_url' => $this->poster ? asset('storage/' . $this->poster) : null, | |
| 'is_active' => $this->is_active, | |
| 'genres' => GenreResource::collection($this->whenLoaded('genres')), | |
| 'created_at' => $this->created_at?->toISOString(), | |
| 'updated_at' => $this->updated_at?->toISOString(), | |
| ]; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment