0) {$dur .= $days . "D";} if ($hours > 0) {$dur .= $hours . "H";} $dur .= $s . "M"; return $dur; } public static function getMovieMarkupData($mov) { $movie = Schema::movie() ->name($mov->title) ->description($mov->title.' - '.$mov->overview) ->image(img_url('w300', $mov->poster_path, true )) ->url(item($mov)->link) ->duration(self::MinutesToDuration($mov->runtime)) ->genre(collect($mov->genres)->pluck('name')->all()) ->keywords(collect($mov->keywords->keywords)->implode('name', ',')) ->datePublished($mov->release_date); if (isset($mov->vote_average)) { $rating = Schema::aggregateRating() ->bestRating(10) ->worstRating(1) ->ratingValue($mov->vote_average) ->ratingCount($mov->vote_count) ->ratingExplanation('Community Rating'); $movie->aggregateRating($rating); } $actors = []; foreach( collect($mov->credits->cast)->take(5) as $cast) { $actors[]=Schema::person()->name($cast->name)->image(img_url('w185', $cast->profile_path)); } $movie->actor($actors); $directors = []; foreach( collect($mov->credits->crew)->filter(function($value, $key){ return $value->job === 'Director';}) as $cast) { $directors[]=Schema::person()->name($cast->name); } $movie->director($directors); return $movie->toScript(); } } // function dd($v) { // var_dump($v); // exit; // } function getTvMarkupData($mov) { // dd($mov); // dd($mov['keywords']); if (isset($mov->vote_average)) { $rating = Schema::aggregateRating() ->bestRating(10) ->worstRating(1) ->ratingValue($mov->vote_average) ->ratingCount($mov->vote_count) ->ratingExplanation('Community Rating'); } $movie = Schema::tVSeries() ->name($mov->name) ->description($mov->name.' - '.$mov->overview) ->image(img_url('w300', $mov->poster_path, true )) ->url(item($mov)->link) // ->duration(MinutesToDuration($mov['episode_run_time'][0])) ->genre(collect($mov->genres)->pluck('name')->toArray()) ->keywords(collect($mov->keywords->results)->implode('name', ',')) ->datePublished($mov->first_air_date) ->numberOfEpisodes($mov->number_of_episodes) ->numberOfSeasons($mov->number_of_seasons) ; if (isset($rating)) { $movie->aggregateRating($rating); } $actors = []; foreach( collect($mov->credits->cast)->take(5) as $cast) { $actors[]=Schema::person()->name($cast->name)->image(img_url('w185', $cast->profile_path)); } $movie->actor($actors); $directors = []; foreach( collect($mov->credits->crew)->filter(function($value, $key){ return $value->job === 'Producer' || $value->job === 'Executive Producer';})->take(5) as $cast) { $directors[]=Schema::person()->name($cast->name); } $movie->creator($directors); return $movie->toScript(); } function getTvSeasonMarkupData($mov) { // dd($mov); // dd($mov['keywords']); $rating = Schema::aggregateRating() ->bestRating(10) ->worstRating(1) ->ratingValue($mov['vote_average']) ->ratingCount($mov['vote_count']) ->ratingExplanation('Community Rating'); $movie = Schema::tVSeries() ->name($mov->name) ->description($mov->name.' - '.$mov['overview']) ->image(img_url('w300', $mov['poster_path'], true )) ->url(build_permalink('tv/' . $mov['id'] .'/' .str_slug($mov->name))) // ->duration(MinutesToDuration($mov['episode_run_time'][0])) ->aggregateRating($rating) ->genre(collect($mov['genres'])->pluck('name')->toArray()) ->keywords(collect($mov['keywords']['results'])->implode('name', ',')) ->datePublished($mov['first_air_date']) ->numberOfEpisodes($mov['number_of_episodes']) ->numberOfSeasons($mov['number_of_seasons']) ; $actors = []; foreach( collect($mov['credits']['cast'])->take(5) as $cast) { $actors[]=Schema::person()->name($cast['name'])->url(build_permalink('people/'.str_slug($cast['name']).'/'.$cast['id']))->image(img_url('w185', $cast['profile_path'])); } $movie->actor($actors); $directors = []; foreach( collect($mov['credits']['crew'])->filter(function($value, $key){ return $value['job'] === 'Producer' || $value['job'] === 'Executive Producer';})->take(5) as $cast) { $directors[]=Schema::person()->name($cast['name']); } $movie->creator($directors); return $movie->toScript(); }