Closed sherwinmartin closed 7 years ago
@w1n78 not sure if you resolved this yet or not, but this should do the trick.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Tmdb\Helper\ImageHelper;
use Tmdb\Repository\MovieRepository;
use Tmdb\Repository\SearchRepository;
use Tmdb\Model\Search\SearchQuery\MovieSearchQuery;
class TmdbController extends Controller
{
private $movies;
private $helper;
public function __construct(MovieRepository $movies, ImageHelper $helper, SearchRepository $search)
{
$this->movies = $movies;
$this->helper = $helper;
$this->search = $search;
}
public function search()
{
$data = [
'page_title' => 'Search TMDB',
'navi_group' => 'search',
'navi_submenu' => 'search',
'results' => $this->search->searchMovie('batman', new MovieSearchQuery)
];
return view('tmdb.search', $data);
}
}
@devnick thank you so much. i knew i was missing something. i was so close haha. i also assume all the methods are found in \Tmdb\Model\Movie.php right? i wish there were more sample code. i have a hard time understanding some times
@w1n78 No problem! You are correct in that the individual Movie objects contain all of the methods required to retrieve the data necessary for each item.
I agree with you in terms of the sparse documentation. An organized Wiki would certainly be nice, but fortunately the source code is documented quite well and the there are several typical examples there that help to put things in perspective.
Also, just an FYI, on this call:
$this->search->searchMovie('batman', new MovieSearchQuery)
you'll probably want to chain the toArray()
method on it to get an actual returnable dataset back from the searchMovie()
method. So:
$this->search->searchMovie('batman', new MovieSearchQuery)->toArray()
should get you the data you want.
@devnick ok cool thanks. yes, i found the examples but i had to change it so i can use it in laravel. i was so close just couldn't get that second argument to work haha. once i get used to it, i'll probably contribute some example code i use in the wiki that uses laravel. thanks again. i'm rewriting an old codeigniter app i had done a few years ago using the tmdb api. i'm just rusty.
In case you (or someone else reading this) hadn't seen the examples from the original php-tmdb/api
repo, here is a link.
Please feel free to send any Pull Request on documentation, code or anything you like. Both me and @wtfzdotnet don't (actively?) use this project so it's hard to come up with useful documentation.
Hey Guys,
I used to use this project for an in-house application to show and list movies that used to be on a certain machine :-). I however since moved to alternatives and pretty much abandoned this application.
We could really use the help of the community to keep maintaining this library, I still maintain the base library on a "sort of common basis", but I'd really prefer the community taking over and just supervising the pull requests.
That said, any attributions to any of the projects in our organisation whether it's documentation or code additions or modifications, they are more than welcome! And I would really encourage you to do so, if you have any questions about the inner workings of php-tmdb/api
and help documenting or creating examples that will make it easier for other people that come along after you, please don't hesitate to write me an e-mail :)
hello, i'm trying to search for a movie by title. i can't seem to figure it out. here is my code.
i get this error
i tried to pass 'title' or 'movie' as the second argument and i get a similar error that sounds like it's not supposed to be a string. i know i'm doing something wrong. hope someone can help. thanks.