This commit is contained in:
denisdulici 2017-09-18 17:31:43 +03:00
parent 4ba7734055
commit 80be5c8fd2
3 changed files with 27 additions and 6 deletions

View File

@ -27,11 +27,18 @@ class Users extends ApiController
/** /**
* Display the specified resource. * Display the specified resource.
* *
* @param User $user * @param int|string $id
* @return \Dingo\Api\Http\Response * @return \Dingo\Api\Http\Response
*/ */
public function show(User $user) public function show($id)
{ {
// Check if we're querying by id or email
if (is_numeric($id)) {
$user = User::with(['roles', 'permissions'])->findOrFail($id);
} else {
$user = User::with(['roles', 'permissions'])->where('email', $id)->first();
}
return $this->response->item($user, new Transformer()); return $this->response->item($user, new Transformer());
} }

View File

@ -27,11 +27,18 @@ class Vendors extends ApiController
/** /**
* Display the specified resource. * Display the specified resource.
* *
* @param Vendor $vendor * @param int|string $id
* @return \Dingo\Api\Http\Response * @return \Dingo\Api\Http\Response
*/ */
public function show(Vendor $vendor) public function show($id)
{ {
// Check if we're querying by id or email
if (is_numeric($id)) {
$vendor = Vendor::findOrFail($id);
} else {
$vendor = Vendor::where('email', $id)->first();
}
return $this->response->item($vendor, new Transformer()); return $this->response->item($vendor, new Transformer());
} }

View File

@ -27,11 +27,18 @@ class Customers extends ApiController
/** /**
* Display the specified resource. * Display the specified resource.
* *
* @param Customer $customer * @param int|string $id
* @return \Dingo\Api\Http\Response * @return \Dingo\Api\Http\Response
*/ */
public function show(Customer $customer) public function show($id)
{ {
// Check if we're querying by id or email
if (is_numeric($id)) {
$customer = Customer::findOrFail($id);
} else {
$customer = Customer::where('email', $id)->first();
}
return $this->response->item($customer, new Transformer()); return $this->response->item($customer, new Transformer());
} }