1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 13:42:49 +01:00
invoiceninja/app/Http/Controllers/QuoteApiController.php

66 lines
1.7 KiB
PHP
Raw Normal View History

2015-03-17 02:30:56 +01:00
<?php namespace App\Http\Controllers;
2015-03-16 22:45:25 +01:00
2015-03-17 02:30:56 +01:00
use Utils;
2015-04-08 20:19:58 +02:00
use Response;
use App\Models\Invoice;
use App\Ninja\Repositories\InvoiceRepository;
2015-03-16 22:45:25 +01:00
class QuoteApiController extends Controller
{
protected $invoiceRepo;
public function __construct(InvoiceRepository $invoiceRepo)
{
$this->invoiceRepo = $invoiceRepo;
}
2015-11-08 22:53:13 +01:00
/**
* @SWG\Get(
* path="/quotes",
* tags={"quote"},
* summary="List of quotes",
* @SWG\Response(
* response=200,
* description="A list with quotes",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Invoice"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
2015-09-07 11:07:55 +02:00
public function index($clientPublicId = false)
2015-03-16 22:45:25 +01:00
{
2015-07-30 19:48:59 +02:00
$invoices = Invoice::scope()
->with('client', 'user')
2015-09-07 11:07:55 +02:00
->where('invoices.is_quote', '=', true);
if ($clientPublicId) {
$invoices->whereHas('client', function($query) use ($clientPublicId) {
$query->where('public_id', '=', $clientPublicId);
});
}
$invoices = $invoices->orderBy('created_at', 'desc')->get();
2015-07-02 22:21:29 +02:00
$invoices = Utils::remapPublicIds($invoices);
2015-03-16 22:45:25 +01:00
$response = json_encode($invoices, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders(count($invoices));
return Response::make($response, 200, $headers);
}
/*
public function store()
{
$data = Input::all();
$invoice = $this->invoiceRepo->save(false, $data, false);
$response = json_encode($invoice, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders();
return Response::make($response, 200, $headers);
}
*/
}