@douglasakula @stevecove
verified that I have migration and seeding done for the table i need to pull, it seems like I am missing the model that controller talk to database
I have resource file with
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class MovieResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'type' => 'movie',
'id' => $this->id,
'title' => $this->title,
'format' => $this->format
];
}
}
controller file that's boiler plate from running make:controller --resource controller
namespace App\Http\Controllers;
public function show($id)
{
return new MovieResource($id);
}
I already have a model class that makes the DB call for get, update, delete operation for regular routes that retrieve data, which looks like this
namespace App\Http\Models;
public function get($num = null){
if ($num === null){
$return = DB::table('movie')->get();
} else {
$return = DB::table('movie')->select()->limit($num)->get();
}
return $return;
}
but I don't know how to connect this to my API route which is Route::get('movie/{id}', 'MovieController@show');