added model check to api show endpoints

This commit is contained in:
Denis Duliçi
2022-07-20 10:54:13 +03:00
parent ef24b51142
commit fa9be87e37
9 changed files with 37 additions and 0 deletions

View File

@ -48,6 +48,10 @@ class DocumentTransactions extends ApiController
{
$transaction = Transaction::documentId($document_id)->find($id);
if (! $transaction instanceof Transaction) {
return $this->errorInternal('No query results for model [' . Transaction::class . '] ' . $id);
}
return new Resource($transaction);
}

View File

@ -39,6 +39,10 @@ class Documents extends ApiController
$document = Document::where('document_number', $id)->first();
}
if (! $document instanceof Document) {
return $this->errorInternal('No query results for model [' . Document::class . '] ' . $id);
}
return new Resource($document);
}