ApiController "protect $fractal" line is just a typo in your paste or is it in your code?
How do you call your controller?
I call "ApiController That Error" By
// ArticleController
class ArticleController extends ApiController {
private $MyRepo;
function __construct(MyRepositoryInterface $MyRepo)
{
$this->MyRepo = $MyRepo;
}
public function getArticle()
{
// I have got article collection
return Response::json($this->respondCollectionWithJson($article, new ArticleTransformer));
}
}
On my
class ApiController extends BaseController {
protect $fractal
public function __construct(Manager $fractal)
{
$this->fractal = $fractal;
}
protected function respondCollectionWithJson($resource)
{
$resource = new Collection($collection, $callback);
return $this->fractal->createData($resource)->toArray();
}
}
I don't understand why I can't use "$this->fractal"
call parent::__construct() in your ArticleControllers constructor!
And in your ApiController it's a typo i think: "protect $fractal"
PaddyHu said:
call parent::__construct() in your ArticleControllers constructor!
And in your ApiController it's a typo i think: "protect $fractal"
It work! Thank you very much.
"protect $fractal" sorry my mistake.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community