pixelead0 / tmdb_v3-PHP-API-

Wrapper in PHP for The Movie Data Base version 3
119 stars 81 forks source link

how to get crew for movie Persons #48

Closed lyarinet closed 6 years ago

lyarinet commented 7 years ago

how to get crew for movie Persons

bogdanfinn commented 7 years ago

For now you can access the crew or the cast of a movie by this sample code:

$movie->get('credits')['cast'] $movie->get('credits')['crew']

Notice, that you only receive the credits when you fetching the detailed movie information by id.

This Methods return arrays with Data for Person Objects. I will add functionality to the Movie Class in a Pull Request for accessing these information with a getter Function returning Person Objects.

bogdanfinn commented 7 years ago

@asifagaria When the Pull Request is accepted you can call getCast() or getCrew() on a detailed Movie or TvShow Object.

webstractions commented 7 years ago

Nice addition!

Not to be nit-picky though. Seems like a little refactoring might be in order. May I suggest using a base data controller? Looks like there several common methods in both the Movie and TV apis.

bogdanfinn commented 7 years ago

@webstractions Yeah it was only a quick solution. Refactoring might be in order. You are right.

lyarinet commented 7 years ago

Please make a example file

webstractions commented 7 years ago

@asifagaria With a little patience, you will see it in the next commit. I just noticed @bogdanfinn added an example in the PR he is working on.

bogdanfinn commented 7 years ago

@webstractions is right. I added an example for cast and crew. ;)

bogdanfinn commented 7 years ago

@webstractions @asifagaria I refactored the Movie and the TVShow classes with a base class for the same methods. Later we should think about refactoring the other classes (Episode, Season, Person, etc.) but i think that should be in another PR. Also we should add some more checks to avoid possible exceptions.

I also added an example for accessing cast and crew pictures from movie and tvshow objects.

bogdanfinn commented 6 years ago

@pixelead0 Issue can be closed, because of the merged PR.