Renamed the attach query paramter of API controllers to with

This commit is contained in:
Alex Tselegidis 2021-11-06 15:41:11 +01:00
parent c68565e2c3
commit e38df7452b
9 changed files with 47 additions and 47 deletions

View file

@ -52,7 +52,7 @@ class Admins_api_v1 extends EA_Controller {
$fields = $this->api->request_fields();
$attach = $this->api->request_attach();
$with = $this->api->request_with();
$admins = empty($keyword)
? $this->admins_model->get(NULL, $limit, $offset, $order_by)
@ -67,9 +67,9 @@ class Admins_api_v1 extends EA_Controller {
$this->admins_model->only($admin, $fields);
}
if ( ! empty($attach))
if ( ! empty($with))
{
$this->admins_model->attach($admin, $attach);
$this->admins_model->load($admin, $with);
}
}
@ -92,7 +92,7 @@ class Admins_api_v1 extends EA_Controller {
{
$fields = $this->api->request_fields();
$attach = $this->api->request_attach();
$with = $this->api->request_with();
$admin = $this->admins_model->find($id);
@ -103,9 +103,9 @@ class Admins_api_v1 extends EA_Controller {
$this->admins_model->only($admin, $fields);
}
if ( ! empty($attach))
if ( ! empty($with))
{
$this->admins_model->attach($admin, $attach);
$this->admins_model->load($admin, $with);
}
if ( ! $admin)

View file

@ -58,7 +58,7 @@ class Appointments_api_v1 extends EA_Controller {
$fields = $this->api->request_fields();
$attach = $this->api->request_attach();
$with = $this->api->request_with();
$appointments = empty($keyword)
? $this->appointments_model->get(NULL, $limit, $offset, $order_by)
@ -75,9 +75,9 @@ class Appointments_api_v1 extends EA_Controller {
$this->appointments_model->only($appointment, $fields);
}
if ( ! empty($attach))
if ( ! empty($with))
{
$this->appointments_model->attach($appointment, $attach);
$this->appointments_model->load($appointment, $with);
}
}
@ -100,7 +100,7 @@ class Appointments_api_v1 extends EA_Controller {
{
$fields = $this->api->request_fields();
$attach = $this->api->request_attach();
$with = $this->api->request_with();
$appointment = $this->appointments_model->find($id);
@ -111,9 +111,9 @@ class Appointments_api_v1 extends EA_Controller {
$this->appointments_model->only($appointment, $fields);
}
if ( ! empty($attach))
if ( ! empty($with))
{
$this->appointments_model->attach($appointment, $attach);
$this->appointments_model->load($appointment, $with);
}
if ( ! $appointment)

View file

@ -52,7 +52,7 @@ class Categories_api_v1 extends EA_Controller {
$fields = $this->api->request_fields();
$attach = $this->api->request_attach();
$with = $this->api->request_with();
$service_categories = empty($keyword)
? $this->service_categories_model->get(NULL, $limit, $offset, $order_by)
@ -67,9 +67,9 @@ class Categories_api_v1 extends EA_Controller {
$this->service_categories_model->only($service_category, $fields);
}
if ( ! empty($attach))
if ( ! empty($with))
{
$this->service_categories_model->attach($service_category, $attach);
$this->service_categories_model->load($service_category, $with);
}
}
@ -92,7 +92,7 @@ class Categories_api_v1 extends EA_Controller {
{
$fields = $this->api->request_fields();
$attach = $this->api->request_attach();
$with = $this->api->request_with();
$service_category = $this->service_categories_model->find($id);
@ -103,9 +103,9 @@ class Categories_api_v1 extends EA_Controller {
$this->service_categories_model->only($service_category, $fields);
}
if ( ! empty($attach))
if ( ! empty($with))
{
$this->service_categories_model->attach($service_category, $attach);
$this->service_categories_model->load($service_category, $with);
}
if ( ! $service_category)

View file

@ -52,7 +52,7 @@ class Customers_api_v1 extends EA_Controller {
$fields = $this->api->request_fields();
$attach = $this->api->request_attach();
$with = $this->api->request_with();
$customers = empty($keyword)
? $this->customers_model->get(NULL, $limit, $offset, $order_by)
@ -67,9 +67,9 @@ class Customers_api_v1 extends EA_Controller {
$this->customers_model->only($customer, $fields);
}
if ( ! empty($attach))
if ( ! empty($with))
{
$this->customers_model->attach($customer, $attach);
$this->customers_model->load($customer, $with);
}
}

View file

@ -52,7 +52,7 @@ class Providers_api_v1 extends EA_Controller {
$fields = $this->api->request_fields();
$attach = $this->api->request_attach();
$with = $this->api->request_with();
$providers = empty($keyword)
? $this->providers_model->get(NULL, $limit, $offset, $order_by)
@ -67,9 +67,9 @@ class Providers_api_v1 extends EA_Controller {
$this->providers_model->only($provider, $fields);
}
if ( ! empty($attach))
if ( ! empty($with))
{
$this->providers_model->attach($provider, $attach);
$this->providers_model->load($provider, $with);
}
}
@ -92,7 +92,7 @@ class Providers_api_v1 extends EA_Controller {
{
$fields = $this->api->request_fields();
$attach = $this->api->request_attach();
$with = $this->api->request_with();
$provider = $this->providers_model->find($id);
@ -103,9 +103,9 @@ class Providers_api_v1 extends EA_Controller {
$this->providers_model->only($provider, $fields);
}
if ( ! empty($attach))
if ( ! empty($with))
{
$this->providers_model->attach($provider, $attach);
$this->providers_model->load($provider, $with);
}
if ( ! $provider)

View file

@ -52,7 +52,7 @@ class Secretaries_api_v1 extends EA_Controller {
$fields = $this->api->request_fields();
$attach = $this->api->request_attach();
$with = $this->api->request_with();
$secretaries = empty($keyword)
? $this->secretaries_model->get(NULL, $limit, $offset, $order_by)
@ -67,9 +67,9 @@ class Secretaries_api_v1 extends EA_Controller {
$this->secretaries_model->only($secretary, $fields);
}
if ( ! empty($attach))
if ( ! empty($with))
{
$this->secretaries_model->attach($secretary, $attach);
$this->secretaries_model->load($secretary, $with);
}
}

View file

@ -52,7 +52,7 @@ class Services_api_v1 extends EA_Controller {
$fields = $this->api->request_fields();
$attach = $this->api->request_attach();
$with = $this->api->request_with();
$services = empty($keyword)
? $this->services_model->get(NULL, $limit, $offset, $order_by)
@ -67,9 +67,9 @@ class Services_api_v1 extends EA_Controller {
$this->services_model->only($service, $fields);
}
if ( ! empty($attach))
if ( ! empty($with))
{
$this->services_model->attach($service, $attach);
$this->services_model->load($service, $with);
}
}
@ -92,7 +92,7 @@ class Services_api_v1 extends EA_Controller {
{
$fields = $this->api->request_fields();
$attach = $this->api->request_attach();
$with = $this->api->request_with();
$service = $this->services_model->find($id);
@ -103,9 +103,9 @@ class Services_api_v1 extends EA_Controller {
$this->services_model->only($service, $fields);
}
if ( ! empty($attach))
if ( ! empty($with))
{
$this->services_model->attach($service, $attach);
$this->services_model->load($service, $with);
}
if ( ! $service)

View file

@ -52,7 +52,7 @@ class Unavailabilities_api_v1 extends EA_Controller {
$fields = $this->api->request_fields();
$attach = $this->api->request_attach();
$with = $this->api->request_with();
$unavailabilities = empty($keyword)
? $this->unavailabilities_model->get(NULL, $limit, $offset, $order_by)
@ -67,9 +67,9 @@ class Unavailabilities_api_v1 extends EA_Controller {
$this->unavailabilities_model->only($unavailability, $fields);
}
if ( ! empty($attach))
if ( ! empty($with))
{
$this->unavailabilities_model->attach($unavailability, $attach);
$this->unavailabilities_model->load($unavailability, $with);
}
}
@ -92,7 +92,7 @@ class Unavailabilities_api_v1 extends EA_Controller {
{
$fields = $this->api->request_fields();
$attach = $this->api->request_attach();
$with = $this->api->request_with();
$unavailability = $this->unavailabilities_model->find($id);
@ -103,9 +103,9 @@ class Unavailabilities_api_v1 extends EA_Controller {
$this->unavailabilities_model->only($unavailability, $fields);
}
if ( ! empty($attach))
if ( ! empty($with))
{
$this->unavailabilities_model->attach($unavailability, $attach);
$this->unavailabilities_model->load($unavailability, $with);
}
if ( ! $unavailability)

View file

@ -281,19 +281,19 @@ class Api {
}
/**
* Get the provided "attach" array of the current request.
* Get the provided "with" array of the current request.
*
* @return array|null
*/
public function request_attach(): ?array
public function request_with(): ?array
{
$attach = request('attach');
$with = request('with');
if ( ! $attach)
if ( ! $with)
{
return NULL;
}
return array_map('trim', explode(',', $attach));
return array_map('trim', explode(',', $with));
}
}