O'Reilly logo

Laravel Application Development Blueprints by Halil İbrahim Yılmaz, Arda Kılıçdağı

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Querying the API

We need two controller files for our RESTful route functions. Let's create two controller files under app/controllers/. The files should be named MovieController.php and ActorController.php.

Getting movie/actor information from the API

First, we need the getActorInfo() and getMovieInfo() functions for getting actor and movie information from the database. Open the ActorController.php file located at app/controllers/ and write the following code:

<?php class ActorController extends BaseController { public function getActorInfo($actorname){ $actor = Actor::where('name', 'like', '%'.$actorname.'%')->first(); if($actor){ $actorInfo = array('error'=>false,'Actor Name'=>$actor->name,'Actor ID'=>$actor->id); $actormovies = json_decode($actor->Movies); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required