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