added model check to api show endpoints
This commit is contained in:
@ -42,6 +42,11 @@ class Contacts extends ApiController
|
||||
$contact = Contact::where('email', $id)->first();
|
||||
}
|
||||
|
||||
if (! $contact instanceof Contact) {
|
||||
//return $this->noContent();
|
||||
return $this->errorInternal('No query results for model [' . Contact::class . '] ' . $id);
|
||||
}
|
||||
|
||||
return new Resource($contact);
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,10 @@ class Dashboards extends ApiController
|
||||
try {
|
||||
$dashboard = Dashboard::with('widgets')->find($id);
|
||||
|
||||
if (! $dashboard instanceof Dashboard) {
|
||||
return $this->errorInternal('No query results for model [' . Dashboard::class . '] ' . $id);
|
||||
}
|
||||
|
||||
// Check if user can access dashboard
|
||||
$this->canAccess($dashboard);
|
||||
|
||||
|
@ -34,6 +34,10 @@ class Items extends ApiController
|
||||
{
|
||||
$item = Item::with('category', 'taxes')->find($id);
|
||||
|
||||
if (! $item instanceof Item) {
|
||||
return $this->errorInternal('No query results for model [' . Item::class . '] ' . $id);
|
||||
}
|
||||
|
||||
return new Resource($item);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user