1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Http/Controllers/BaseAPIController.php
2015-11-03 21:03:24 +02:00

29 lines
669 B
PHP

<?php namespace App\Http\Controllers;
use Utils;
use Response;
use League\Fractal;
use League\Fractal\Manager;
use App\Ninja\Serializers\ArraySerializer;
class BaseAPIController extends Controller
{
protected $manager;
public function __construct()
{
$this->manager = new Manager();
$this->manager->setSerializer(new ArraySerializer());
}
protected function returnData($resource)
{
$response = $this->manager->createData($resource)->toArray();
$response = json_encode($response, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders();
return Response::make($response, 200, $headers);
}
}