mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
29 lines
669 B
PHP
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);
|
|
}
|
|
|
|
}
|