This commit is contained in:
cuneytsenturk 2017-09-18 18:36:49 +03:00
commit 2d9bd5f540
12 changed files with 35 additions and 18 deletions

View File

@ -27,13 +27,11 @@ class Roles extends ApiController
/**
* Display the specified resource.
*
* @param int $id
* @param Role $role
* @return \Dingo\Api\Http\Response
*/
public function show($id)
public function show(Role $role)
{
$role = Role::with('permissions')->findOrFail($id);
return $this->response->item($role, new Transformer());
}

View File

@ -27,12 +27,17 @@ class Users extends ApiController
/**
* Display the specified resource.
*
* @param int $id
* @param int|string $id
* @return \Dingo\Api\Http\Response
*/
public function show($id)
{
$user = User::with(['roles', 'permissions'])->findOrFail($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());
}

View File

@ -27,7 +27,7 @@ class Bills extends ApiController
*/
public function index()
{
$bills = Bill::with('bill_statuses')->collect();
$bills = Bill::with(['vendor', 'status', 'items', 'payments', 'histories'])->collect();
return $this->response->paginator($bills, new Transformer());
}

View File

@ -19,7 +19,7 @@ class Payments extends ApiController
*/
public function index()
{
$payments = Payment::with('account', 'vendor', 'category')->collect();
$payments = Payment::with(['account', 'vendor', 'category'])->collect();
return $this->response->paginator($payments, new Transformer());
}

View File

@ -27,11 +27,18 @@ class Vendors extends ApiController
/**
* Display the specified resource.
*
* @param Vendor $vendor
* @param int|string $id
* @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());
}

View File

@ -27,11 +27,18 @@ class Customers extends ApiController
/**
* Display the specified resource.
*
* @param Customer $customer
* @param int|string $id
* @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());
}

View File

@ -27,7 +27,7 @@ class Invoices extends ApiController
*/
public function index()
{
$invoices = Invoice::with('invoice_statuses')->collect();
$invoices = Invoice::with(['customer', 'status', 'items', 'payments', 'histories'])->collect();
return $this->response->paginator($invoices, new Transformer());
}

View File

@ -19,7 +19,7 @@ class Revenues extends ApiController
*/
public function index()
{
$revenues = Revenue::with('account', 'customer', 'category')->collect();
$revenues = Revenue::with(['account', 'customer', 'category'])->collect();
return $this->response->paginator($revenues, new Transformer());
}

View File

@ -36,7 +36,7 @@ class Bills extends Controller
*/
public function index()
{
$bills = Bill::with('bill_statuses')->collect();
$bills = Bill::with('status')->collect();
$status = collect(BillStatus::all()->pluck('name', 'code'))
->prepend(trans('general.all_statuses'), '');

View File

@ -22,7 +22,7 @@ class Payments extends Controller
*/
public function index()
{
$payments = Payment::with('account', 'category')->collect();
$payments = Payment::with(['account', 'category'])->collect();
$categories = collect(Category::enabled()->type('expense')->pluck('name', 'id'))
->prepend(trans('categories.all'), '');

View File

@ -38,7 +38,7 @@ class Invoices extends Controller
*/
public function index()
{
$invoices = Invoice::with('invoice_statuses')->collect();
$invoices = Invoice::with('status')->collect();
$status = collect(InvoiceStatus::all()->pluck('name', 'code'))
->prepend(trans('general.all_statuses'), '');

View File

@ -25,7 +25,7 @@ class Revenues extends Controller
*/
public function index()
{
$revenues = Revenue::with('account', 'category', 'customer')->collect();
$revenues = Revenue::with(['account', 'category', 'customer'])->collect();
$customers = collect(Customer::enabled()->pluck('name', 'id'))
->prepend(trans('customer.all'), '');