get api invoice by number

This commit is contained in:
denisdulici 2018-03-28 15:30:00 +03:00
parent 4d05971b50
commit 6dec413786

View File

@ -36,11 +36,18 @@ class Invoices extends ApiController
/** /**
* Display the specified resource. * Display the specified resource.
* *
* @param Invoice $invoice * @param $id
* @return \Dingo\Api\Http\Response * @return \Dingo\Api\Http\Response
*/ */
public function show(Invoice $invoice) public function show($id)
{ {
// Check if we're querying by id or number
if (is_numeric($id)) {
$invoice = Invoice::find($id);
} else {
$invoice = Invoice::where('invoice_number', $id)->first();
}
return $this->response->item($invoice, new Transformer()); return $this->response->item($invoice, new Transformer());
} }