Rearrange main controller create/update commands

This commit is contained in:
Alex Tselegidis 2022-03-25 12:50:40 +01:00
parent cb410f739d
commit 1b20f49f9d
6 changed files with 30 additions and 30 deletions

View file

@ -85,13 +85,13 @@ class Appointments extends EA_Controller {
{ {
try try
{ {
$appointment = json_decode(request('appointment'), TRUE);
if (cannot('add', PRIV_APPOINTMENTS)) if (cannot('add', PRIV_APPOINTMENTS))
{ {
abort(403, 'Forbidden'); abort(403, 'Forbidden');
} }
$appointment = json_decode(request('appointment'), TRUE);
$this->appointments_model->only($appointment, [ $this->appointments_model->only($appointment, [
'start_datetime', 'start_datetime',
'end_datetime', 'end_datetime',
@ -124,13 +124,13 @@ class Appointments extends EA_Controller {
{ {
try try
{ {
$appointment = json_decode(request('appointment'), TRUE);
if (cannot('edit', PRIV_APPOINTMENTS)) if (cannot('edit', PRIV_APPOINTMENTS))
{ {
abort(403, 'Forbidden'); abort(403, 'Forbidden');
} }
$appointment = json_decode(request('appointment'), TRUE);
$this->appointments_model->only($appointment, [ $this->appointments_model->only($appointment, [
'id', 'id',
'start_datetime', 'start_datetime',

View file

@ -159,13 +159,13 @@ class Customers extends EA_Controller {
{ {
try try
{ {
$customer = request('customer');
if (cannot('add', PRIV_USERS)) if (cannot('add', PRIV_USERS))
{ {
abort(403, 'Forbidden'); abort(403, 'Forbidden');
} }
$customer = request('customer');
$customer_id = $this->customers_model->save($customer); $customer_id = $this->customers_model->save($customer);
json_response([ json_response([
@ -186,13 +186,13 @@ class Customers extends EA_Controller {
{ {
try try
{ {
$customer = request('customer');
if (cannot('edit', PRIV_USERS)) if (cannot('edit', PRIV_USERS))
{ {
abort(403, 'Forbidden'); abort(403, 'Forbidden');
} }
$customer = request('customer');
$customer_id = $this->customers_model->save($customer); $customer_id = $this->customers_model->save($customer);
json_response([ json_response([

View file

@ -128,13 +128,13 @@ class Providers extends EA_Controller {
{ {
try try
{ {
$provider = request('provider');
if (cannot('add', PRIV_USERS)) if (cannot('add', PRIV_USERS))
{ {
abort(403, 'Forbidden'); abort(403, 'Forbidden');
} }
$provider = request('provider');
$provider_id = $this->providers_model->save($provider); $provider_id = $this->providers_model->save($provider);
json_response([ json_response([
@ -155,13 +155,13 @@ class Providers extends EA_Controller {
{ {
try try
{ {
$provider = request('provider');
if (cannot('edit', PRIV_USERS)) if (cannot('edit', PRIV_USERS))
{ {
abort(403, 'Forbidden'); abort(403, 'Forbidden');
} }
$provider = request('provider');
$provider_id = $this->providers_model->save($provider); $provider_id = $this->providers_model->save($provider);
json_response([ json_response([

View file

@ -128,13 +128,13 @@ class Secretaries extends EA_Controller {
{ {
try try
{ {
$secretary = request('secretary');
if (cannot('add', PRIV_USERS)) if (cannot('add', PRIV_USERS))
{ {
abort(403, 'Forbidden'); abort(403, 'Forbidden');
} }
$secretary = request('secretary');
$secretary_id = $this->secretaries_model->save($secretary); $secretary_id = $this->secretaries_model->save($secretary);
json_response([ json_response([
@ -155,13 +155,13 @@ class Secretaries extends EA_Controller {
{ {
try try
{ {
$secretary = request('secretary');
if (cannot('edit', PRIV_USERS)) if (cannot('edit', PRIV_USERS))
{ {
abort(403, 'Forbidden'); abort(403, 'Forbidden');
} }
$secretary = request('secretary');
$secretary_id = $this->secretaries_model->save($secretary); $secretary_id = $this->secretaries_model->save($secretary);
json_response([ json_response([

View file

@ -113,15 +113,15 @@ class Services extends EA_Controller {
{ {
try try
{ {
$service = request('service');
$service['id_categories'] = $service['id_categories'] ?: null;
if (cannot('add', PRIV_SERVICES)) if (cannot('add', PRIV_SERVICES))
{ {
abort(403, 'Forbidden'); abort(403, 'Forbidden');
} }
$service = request('service');
$service['id_categories'] = $service['id_categories'] ?: null;
$service_id = $this->services_model->save($service); $service_id = $this->services_model->save($service);
json_response([ json_response([
@ -142,15 +142,15 @@ class Services extends EA_Controller {
{ {
try try
{ {
$service = request('service');
$service['id_categories'] = $service['id_categories'] ?: null;
if (cannot('edit', PRIV_SERVICES)) if (cannot('edit', PRIV_SERVICES))
{ {
abort(403, 'Forbidden'); abort(403, 'Forbidden');
} }
$service = request('service');
$service['id_categories'] = $service['id_categories'] ?: null;
$service_id = $this->services_model->save($service); $service_id = $this->services_model->save($service);
json_response([ json_response([

View file

@ -70,13 +70,13 @@ class Unavailabilities extends EA_Controller {
{ {
try try
{ {
$unavailability = json_decode(request('unavailability'), TRUE);
if (cannot('add', PRIV_APPOINTMENTS)) if (cannot('add', PRIV_APPOINTMENTS))
{ {
abort(403, 'Forbidden'); abort(403, 'Forbidden');
} }
$unavailability = json_decode(request('unavailability'), TRUE);
$unavailability_id = $this->unavailabilities_model->save($unavailability); $unavailability_id = $this->unavailabilities_model->save($unavailability);
json_response([ json_response([
@ -97,13 +97,13 @@ class Unavailabilities extends EA_Controller {
{ {
try try
{ {
$unavailability = json_decode(request('unavailability'), TRUE);
if (cannot('edit', PRIV_APPOINTMENTS)) if (cannot('edit', PRIV_APPOINTMENTS))
{ {
abort(403, 'Forbidden'); abort(403, 'Forbidden');
} }
$unavailability = json_decode(request('unavailability'), TRUE);
$unavailability_id = $this->unavailabilities_model->save($unavailability); $unavailability_id = $this->unavailabilities_model->save($unavailability);
json_response([ json_response([