get item by sku in api
This commit is contained in:
parent
1a53c60082
commit
033674666f
@ -34,7 +34,7 @@ class Users extends ApiController
|
||||
{
|
||||
// Check if we're querying by id or email
|
||||
if (is_numeric($id)) {
|
||||
$user = User::with(['companies', 'roles', 'permissions'])->findOrFail($id);
|
||||
$user = User::with(['companies', 'roles', 'permissions'])->find($id);
|
||||
} else {
|
||||
$user = User::with(['companies', 'roles', 'permissions'])->where('email', $id)->first();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class Vendors extends ApiController
|
||||
{
|
||||
// Check if we're querying by id or email
|
||||
if (is_numeric($id)) {
|
||||
$vendor = Vendor::findOrFail($id);
|
||||
$vendor = Vendor::find($id);
|
||||
} else {
|
||||
$vendor = Vendor::where('email', $id)->first();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class Customers extends ApiController
|
||||
{
|
||||
// Check if we're querying by id or email
|
||||
if (is_numeric($id)) {
|
||||
$customer = Customer::findOrFail($id);
|
||||
$customer = Customer::find($id);
|
||||
} else {
|
||||
$customer = Customer::where('email', $id)->first();
|
||||
}
|
||||
|
@ -27,11 +27,18 @@ class Items extends ApiController
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param Item $item
|
||||
* @param int|string $id
|
||||
* @return \Dingo\Api\Http\Response
|
||||
*/
|
||||
public function show(Item $item)
|
||||
public function show($id)
|
||||
{
|
||||
// Check if we're querying by id or sku
|
||||
if (is_numeric($id)) {
|
||||
$item = Item::with(['category', 'tax'])->find($id);
|
||||
} else {
|
||||
$item = Item::with(['category', 'tax'])->where('sku', $id)->first();
|
||||
}
|
||||
|
||||
return $this->response->item($item, new Transformer());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user