mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-12-29 01:52:24 +03:00
Resolve various PHP inspection issues
This commit is contained in:
parent
08b14b665e
commit
2b552c4535
42 changed files with 240 additions and 258 deletions
|
@ -131,7 +131,6 @@ class Booking extends EA_Controller {
|
|||
$display_login_button = setting('display_login_button');
|
||||
$display_delete_personal_information = setting('display_delete_personal_information');
|
||||
$book_advance_timeout = setting('book_advance_timeout');
|
||||
$future_booking_limit = setting('future_booking_limit');
|
||||
$theme = request('theme', setting('theme', 'default'));
|
||||
|
||||
if (empty($theme) || ! file_exists(__DIR__ . '/../../assets/css/themes/' . $theme . '.min.css'))
|
||||
|
@ -286,7 +285,7 @@ class Booking extends EA_Controller {
|
|||
*
|
||||
* @param string $appointment_hash
|
||||
*/
|
||||
public function reschedule($appointment_hash)
|
||||
public function reschedule(string $appointment_hash)
|
||||
{
|
||||
html_vars(['appointment_hash' => $appointment_hash]);
|
||||
|
||||
|
@ -311,7 +310,7 @@ class Booking extends EA_Controller {
|
|||
|
||||
if (empty($provider_id))
|
||||
{
|
||||
json_response([]);
|
||||
json_response();
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -397,7 +396,7 @@ class Booking extends EA_Controller {
|
|||
// Check if the provider is available for the requested date.
|
||||
$available_hours = $this->availability->get_available_hours($date, $service, $provider);
|
||||
|
||||
if (count($available_hours) > $max_hours_count && (empty($hour) || in_array($hour, $available_hours, FALSE)))
|
||||
if (count($available_hours) > $max_hours_count && (empty($hour) || in_array($hour, $available_hours)))
|
||||
{
|
||||
$provider_id = $provider['id'];
|
||||
|
||||
|
@ -567,7 +566,7 @@ class Booking extends EA_Controller {
|
|||
'time_format' => setting('time_format')
|
||||
];
|
||||
|
||||
$this->synchronization->sync_appointment_saved($appointment, $service, $provider, $customer, $settings, $manage_mode);
|
||||
$this->synchronization->sync_appointment_saved($appointment, $service, $provider, $customer, $settings);
|
||||
|
||||
$this->notifications->notify_appointment_saved($appointment, $service, $provider, $customer, $settings, $manage_mode);
|
||||
|
||||
|
@ -596,7 +595,7 @@ class Booking extends EA_Controller {
|
|||
* Use this method just before the customer confirms the appointment registration. If the selected date was reserved
|
||||
* in the meanwhile, the customer must be prompted to select another time.
|
||||
*
|
||||
* @return int Returns the ID of the provider that is available for the appointment.
|
||||
* @return int|null Returns the ID of the provider that is available for the appointment.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
|
|
|
@ -36,6 +36,8 @@ class Booking_confirmation extends EA_Controller {
|
|||
|
||||
/**
|
||||
* Display the appointment registration success page.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function of()
|
||||
{
|
||||
|
|
|
@ -227,7 +227,7 @@ class Calendar extends EA_Controller {
|
|||
? can('add', PRIV_APPOINTMENTS)
|
||||
: can('edit', PRIV_APPOINTMENTS);
|
||||
|
||||
if ($required_permissions == FALSE)
|
||||
if ( ! $required_permissions)
|
||||
{
|
||||
throw new RuntimeException('You do not have the required permissions for this task.');
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ class Calendar extends EA_Controller {
|
|||
'time_format' => setting('time_format')
|
||||
];
|
||||
|
||||
$this->synchronization->sync_appointment_saved($appointment, $service, $provider, $customer, $settings, $manage_mode);
|
||||
$this->synchronization->sync_appointment_saved($appointment, $service, $provider, $customer, $settings);
|
||||
|
||||
$this->notifications->notify_appointment_saved($appointment, $service, $provider, $customer, $settings, $manage_mode);
|
||||
|
||||
|
@ -411,7 +411,7 @@ class Calendar extends EA_Controller {
|
|||
|
||||
$this->unavailabilities_model->delete($unavailability_id);
|
||||
|
||||
$this->synchronization->sync_appointment_deleted($unavailability, $provider);
|
||||
$this->synchronization->sync_unavailability_deleted($unavailability, $provider);
|
||||
|
||||
$this->webhooks_client->trigger(WEBHOOK_UNAVAILABILITY_DELETE, $unavailability);
|
||||
|
||||
|
|
|
@ -39,8 +39,6 @@ class Google extends EA_Controller {
|
|||
* This method will completely sync the appointments of a provider with his Google Calendar account. The sync period
|
||||
* needs to be relatively small, because a lot of API calls might be necessary and this will lead to consuming the
|
||||
* Google limit for the Calendar API usage.
|
||||
*
|
||||
* @param string $provider_id Provider record to be synced.
|
||||
*/
|
||||
public static function sync(string $provider_id = NULL)
|
||||
{
|
||||
|
@ -166,7 +164,7 @@ class Google extends EA_Controller {
|
|||
}
|
||||
|
||||
}
|
||||
catch (Throwable $e)
|
||||
catch (Throwable)
|
||||
{
|
||||
// Appointment not found on Google Calendar, delete from Easy!Appointments.
|
||||
$CI->appointments_model->delete($appointment['id']);
|
||||
|
@ -285,7 +283,10 @@ class Google extends EA_Controller {
|
|||
*
|
||||
* IMPORTANT: Because it is necessary to authorize the application using the web server flow (see official
|
||||
* documentation of OAuth), every Easy!Appointments installation should use its own calendar api key. So in every
|
||||
* api console account, the "http://path-to-Easy!Appointments/google/oauth_callback" should be included in an allowed redirect URL.
|
||||
* api console account, the "http://path-to-Easy!Appointments/google/oauth_callback" should be included in an
|
||||
* allowed redirect URL.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function oauth_callback()
|
||||
{
|
||||
|
@ -431,7 +432,7 @@ class Google extends EA_Controller {
|
|||
|
||||
$this->providers_model->set_setting($provider_id, 'google_sync', FALSE);
|
||||
|
||||
$this->providers_model->set_setting($provider_id, 'google_token', NULL);
|
||||
$this->providers_model->set_setting($provider_id, 'google_token');
|
||||
|
||||
$this->appointments_model->clear_google_sync_ids($provider_id);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ class Installation extends EA_Controller {
|
|||
{
|
||||
if (is_app_installed())
|
||||
{
|
||||
redirect('');
|
||||
redirect();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -334,7 +334,7 @@ class Appointments_api_v1 extends EA_Controller {
|
|||
'time_format' => setting('time_format')
|
||||
];
|
||||
|
||||
$this->synchronization->sync_appointment_saved($appointment, $service, $provider, $customer, $settings, $manage_mode);
|
||||
$this->synchronization->sync_appointment_saved($appointment, $service, $provider, $customer, $settings);
|
||||
|
||||
$this->notifications->notify_appointment_saved($appointment, $service, $provider, $customer, $settings, $manage_mode);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class EA_Model extends CI_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [];
|
||||
protected array $casts = [];
|
||||
|
||||
/**
|
||||
* EA_Model constructor.
|
||||
|
|
|
@ -22,18 +22,18 @@
|
|||
*
|
||||
* @return string Returns the final asset URL.
|
||||
*/
|
||||
function asset_url($uri = '', $protocol = NULL)
|
||||
function asset_url(string $uri = '', string $protocol = NULL): string
|
||||
{
|
||||
$debug = config('debug');
|
||||
|
||||
$cache_busting_token = ! $debug ? '?' . config('cache_busting_token') : '';
|
||||
|
||||
if (strpos(basename($uri), '.js') !== FALSE && strpos(basename($uri), '.min.js') === FALSE && ! $debug)
|
||||
if (str_contains(basename($uri), '.js') && ! str_contains(basename($uri), '.min.js') && ! $debug)
|
||||
{
|
||||
$uri = str_replace('.js', '.min.js', $uri);
|
||||
}
|
||||
|
||||
if (strpos(basename($uri), '.css') !== FALSE && strpos(basename($uri), '.min.css') === FALSE && ! $debug)
|
||||
if (str_contains(basename($uri), '.css') && ! str_contains(basename($uri), '.min.css') && ! $debug)
|
||||
{
|
||||
$uri = str_replace('.css', '.min.css', $uri);
|
||||
}
|
||||
|
|
|
@ -25,13 +25,13 @@
|
|||
* config(['version' => '1.0.0']);
|
||||
*
|
||||
* @param array|string $key Configuration key.
|
||||
* @param mixed $default Default value in case the requested config has no value.
|
||||
* @param mixed|null $default Default value in case the requested config has no value.
|
||||
*
|
||||
* @return mixed|NULL Returns the requested value or NULL if you assign a new configuration value.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
function config($key, $default = NULL)
|
||||
function config(array|string $key, mixed $default = NULL): mixed
|
||||
{
|
||||
/** @var EA_Controller $CI */
|
||||
$CI = &get_instance();
|
||||
|
@ -71,14 +71,14 @@ if ( ! function_exists('script_vars'))
|
|||
*
|
||||
* script_vars(['version' => '1.0.0']);
|
||||
*
|
||||
* @param array|string $key Configuration key.
|
||||
* @param mixed $default Default value in case the requested config has no value.
|
||||
* @param array|string|null $key Configuration key.
|
||||
* @param mixed|null $default Default value in case the requested config has no value.
|
||||
*
|
||||
* @return mixed|NULL Returns the requested value or NULL if you assign a new configuration value.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
function script_vars($key = NULL, $default = NULL)
|
||||
function script_vars(array|string $key = NULL, mixed $default = NULL): mixed
|
||||
{
|
||||
$script_vars = config('script_vars', []);
|
||||
|
||||
|
@ -120,14 +120,14 @@ if ( ! function_exists('html_vars'))
|
|||
*
|
||||
* html_vars(['title' => 'Test Title']);
|
||||
*
|
||||
* @param array|string $key Variable key.
|
||||
* @param mixed $default Default value in case the requested variable has no value.
|
||||
* @param array|string|null $key Variable key.
|
||||
* @param mixed|null $default Default value in case the requested variable has no value.
|
||||
*
|
||||
* @return mixed|NULL Returns the requested value or NULL if you assign a new configuration value.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
function html_vars($key = NULL, $default = NULL)
|
||||
function html_vars(array|string $key = NULL, mixed $default = NULL): mixed
|
||||
{
|
||||
$html_vars = config('html_vars', []);
|
||||
|
||||
|
@ -169,14 +169,14 @@ if ( ! function_exists('vars'))
|
|||
*
|
||||
* vars(['version' => '1.0.0']);
|
||||
*
|
||||
* @param array|string $key Configuration key.
|
||||
* @param mixed $default Default value in case the requested config has no value.
|
||||
* @param array|string|null $key Configuration key.
|
||||
* @param mixed|null $default Default value in case the requested config has no value.
|
||||
*
|
||||
* @return mixed|NULL Returns the requested value or NULL if you assign a new configuration value.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
function vars($key = NULL, $default = NULL)
|
||||
function vars(array|string $key = NULL, mixed $default = NULL): mixed
|
||||
{
|
||||
return html_vars($key) ?? script_vars($key) ?? $default;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
<?php use JetBrains\PhpStorm\NoReturn;
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
|
@ -22,7 +24,7 @@ if ( ! function_exists('dd'))
|
|||
*
|
||||
* @param mixed ...$vars
|
||||
*/
|
||||
function dd(...$vars)
|
||||
#[NoReturn] function dd(...$vars): void
|
||||
{
|
||||
var_dump($vars);
|
||||
|
||||
|
|
|
@ -21,13 +21,13 @@ if ( ! function_exists('env'))
|
|||
* $debug = env('debug', FALSE);
|
||||
*
|
||||
* @param string $key Environment key.
|
||||
* @param mixed $default Default value in case the requested variable has no value.
|
||||
* @param mixed|null $default Default value in case the requested variable has no value.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
function env(string $key, $default = NULL)
|
||||
function env(string $key, mixed $default = NULL): mixed
|
||||
{
|
||||
if (empty($key))
|
||||
{
|
||||
|
|
|
@ -48,9 +48,9 @@ if ( ! function_exists('component'))
|
|||
* @param array $vars Additional parameters for the component.
|
||||
* @param bool $return Whether to return the HTML or echo it directly.
|
||||
*
|
||||
* @return string Return the HTML if the $return argument is TRUE or NULL.
|
||||
* @return mixed Return the HTML if the $return argument is TRUE or NULL.
|
||||
*/
|
||||
function component(string $component, array $vars = [], bool $return = FALSE)
|
||||
function component(string $component, array $vars = [], bool $return = FALSE): mixed
|
||||
{
|
||||
/** @var EA_Controller $CI */
|
||||
$CI = get_instance();
|
||||
|
@ -66,7 +66,7 @@ if ( ! function_exists('extend'))
|
|||
*
|
||||
* @param $layout
|
||||
*/
|
||||
function extend($layout)
|
||||
function extend($layout): void
|
||||
{
|
||||
config([
|
||||
'layout' => [
|
||||
|
@ -99,7 +99,7 @@ if ( ! function_exists('section'))
|
|||
*
|
||||
* @param string $name
|
||||
*/
|
||||
function section(string $name)
|
||||
function section(string $name): void
|
||||
{
|
||||
$layout = config('layout');
|
||||
|
||||
|
@ -148,7 +148,7 @@ if ( ! function_exists('end_section'))
|
|||
*
|
||||
* @param string $name
|
||||
*/
|
||||
function end_section(string $name)
|
||||
function end_section(string $name): void
|
||||
{
|
||||
$layout = config('layout');
|
||||
|
||||
|
@ -170,7 +170,7 @@ if ( ! function_exists('slot'))
|
|||
*
|
||||
* @param string $name
|
||||
*/
|
||||
function slot(string $name)
|
||||
function slot(string $name): void
|
||||
{
|
||||
$layout = config('layout');
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
*
|
||||
* @return bool Returns whether E!A is installed or not.
|
||||
*/
|
||||
function is_app_installed()
|
||||
function is_app_installed(): bool
|
||||
{
|
||||
$CI =& get_instance();
|
||||
|
||||
|
|
|
@ -26,8 +26,9 @@ if ( ! function_exists('rate_limit'))
|
|||
* @param int $max_requests Number of allowed requests, defaults to 100.
|
||||
* @param int $duration In seconds, defaults to 2 minutes.
|
||||
*/
|
||||
function rate_limit(string $ip, int $max_requests = 100, int $duration = 120)
|
||||
function rate_limit(string $ip, int $max_requests = 100, int $duration = 120): void
|
||||
{
|
||||
/** @var EA_Controller $CI */
|
||||
$CI =& get_instance();
|
||||
|
||||
$rate_limiting = $CI->config->item('rate_limiting');
|
||||
|
|
|
@ -18,9 +18,9 @@ if ( ! function_exists('route_api_resource'))
|
|||
*
|
||||
* @param array $route Route config.
|
||||
* @param string $resource Resource name.
|
||||
* @param string|null $prefix URL prefix (e.g. api/v1/).
|
||||
* @param string $prefix URL prefix (e.g. api/v1/).
|
||||
*/
|
||||
function route_api_resource(array &$route, string $resource, string $prefix = '')
|
||||
function route_api_resource(array &$route, string $resource, string $prefix = ''): void
|
||||
{
|
||||
$route[$prefix . $resource]['post'] = 'api/v1/' . $resource . '_api_v1/store';
|
||||
$route[$prefix . $resource . '/(:num)']['put'] = 'api/v1/' . $resource . '_api_v1/update/$1';
|
||||
|
|
|
@ -26,14 +26,14 @@ if ( ! function_exists('session'))
|
|||
*
|
||||
* session(['logged_in' => FALSE]);
|
||||
*
|
||||
* @param array|string $key Session item key.
|
||||
* @param mixed $default Default value in case the requested session item has no value.
|
||||
* @param array|string|null $key Session item key.
|
||||
* @param mixed|null $default Default value in case the requested session item has no value.
|
||||
*
|
||||
* @return mixed|NULL Returns the requested value or NULL if you assign a new session value.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
function session($key = NULL, $default = NULL)
|
||||
function session(array|string $key = NULL, mixed $default = NULL): mixed
|
||||
{
|
||||
/** @var EA_Controller $CI */
|
||||
$CI = &get_instance();
|
||||
|
|
|
@ -26,14 +26,14 @@ if ( ! function_exists('setting'))
|
|||
*
|
||||
* setting(['company_name' => 'ACME Inc']);
|
||||
*
|
||||
* @param array|string $key Setting key.
|
||||
* @param mixed $default Default value in case the requested setting has no value.
|
||||
* @param array|string|null $key Setting key.
|
||||
* @param mixed|null $default Default value in case the requested setting has no value.
|
||||
*
|
||||
* @return mixed|NULL Returns the requested value or NULL if you assign a new setting value.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
function setting($key = NULL, $default = NULL)
|
||||
function setting(array|string $key = NULL, mixed $default = NULL): mixed
|
||||
{
|
||||
/** @var EA_Controller $CI */
|
||||
$CI = &get_instance();
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
*/
|
||||
class Accounts {
|
||||
/**
|
||||
* @var EA_Controller
|
||||
* @var EA_Controller|CI_Controller
|
||||
*/
|
||||
protected $CI;
|
||||
protected EA_Controller|CI_Controller $CI;
|
||||
|
||||
/**
|
||||
* Accounts constructor.
|
||||
|
@ -45,6 +45,7 @@ class Accounts {
|
|||
* @param string $password Password (non-hashed).
|
||||
*
|
||||
* @return array|null Returns an associative array with the PHP session data or NULL on failure.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function check_login(string $username, string $password): ?array
|
||||
{
|
||||
|
@ -112,9 +113,9 @@ class Accounts {
|
|||
* @param string $username Username.
|
||||
* @param string $email Email.
|
||||
*
|
||||
* @return string|bool Returns the new password on success or FALSE on failure.
|
||||
* @return string Returns the new password on success or FALSE on failure.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function regenerate_password(string $username, string $email): string
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
<?php use JetBrains\PhpStorm\NoReturn;
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
|
@ -21,19 +23,19 @@
|
|||
*/
|
||||
class Api {
|
||||
/**
|
||||
* @var EA_Controller
|
||||
* @var EA_Controller|CI_Controller
|
||||
*/
|
||||
protected $CI;
|
||||
protected EA_Controller|CI_Controller $CI;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $default_length = 20;
|
||||
protected int $default_length = 20;
|
||||
|
||||
/**
|
||||
* @var EA_Model
|
||||
*/
|
||||
protected $model;
|
||||
protected EA_Model $model;
|
||||
|
||||
/**
|
||||
* Api constructor.
|
||||
|
@ -50,7 +52,7 @@ class Api {
|
|||
*
|
||||
* @param string $model
|
||||
*/
|
||||
public function model(string $model)
|
||||
public function model(string $model): void
|
||||
{
|
||||
$this->CI->load->model($model);
|
||||
|
||||
|
@ -60,7 +62,7 @@ class Api {
|
|||
/**
|
||||
* Authorize the API request (Basic Auth or Bearer Token supported).
|
||||
*/
|
||||
public function auth()
|
||||
public function auth(): void
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -84,7 +86,7 @@ class Api {
|
|||
throw new RuntimeException('The provided credentials do not match any admin user!', 401, 'Unauthorized');
|
||||
}
|
||||
}
|
||||
catch (Throwable $e)
|
||||
catch (Throwable)
|
||||
{
|
||||
$this->request_authentication();
|
||||
}
|
||||
|
@ -93,7 +95,7 @@ class Api {
|
|||
/**
|
||||
* Returns the bearer token value.
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
protected function get_bearer_token(): ?string
|
||||
{
|
||||
|
@ -153,7 +155,7 @@ class Api {
|
|||
/**
|
||||
* Sets request authentication headers.
|
||||
*/
|
||||
public function request_authentication()
|
||||
#[NoReturn] public function request_authentication(): void
|
||||
{
|
||||
header('WWW-Authenticate: Basic realm="Easy!Appointments"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
*/
|
||||
class Availability {
|
||||
/**
|
||||
* @var EA_Controller
|
||||
* @var EA_Controller|CI_Controller
|
||||
*/
|
||||
protected $CI;
|
||||
protected EA_Controller|CI_Controller $CI;
|
||||
|
||||
/**
|
||||
* Availability constructor.
|
||||
|
@ -126,7 +126,7 @@ class Availability {
|
|||
|
||||
$date_working_plan = $working_plan[$working_day] ?? NULL;
|
||||
|
||||
// Search if the $date is an custom availability period added outside the normal working plan.
|
||||
// Search if the $date is a custom availability period added outside the normal working plan.
|
||||
if (isset($working_plan_exceptions[$date]))
|
||||
{
|
||||
$date_working_plan = $working_plan_exceptions[$date];
|
||||
|
@ -145,7 +145,7 @@ class Availability {
|
|||
$day_end = new DateTime($date_working_plan['end']);
|
||||
|
||||
// Split the working plan to available time periods that do not contain the breaks in them.
|
||||
foreach ($date_working_plan['breaks'] as $index => $break)
|
||||
foreach ($date_working_plan['breaks'] as $break)
|
||||
{
|
||||
$break_start = new DateTime($break['start']);
|
||||
$break_end = new DateTime($break['end']);
|
||||
|
@ -373,7 +373,7 @@ class Availability {
|
|||
|
||||
$date_working_plan = $working_plan[$working_day] ?? NULL;
|
||||
|
||||
// Search if the $date is an custom availability period added outside the normal working plan.
|
||||
// Search if the $date is a custom availability period added outside the normal working plan.
|
||||
if (isset($working_plan_exceptions[$date]))
|
||||
{
|
||||
$date_working_plan = $working_plan_exceptions[$date];
|
||||
|
@ -505,7 +505,6 @@ class Availability {
|
|||
{
|
||||
// break contains period
|
||||
$period['start'] = $break_end;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -620,7 +619,7 @@ class Availability {
|
|||
* @param array $available_hours
|
||||
* @param array $provider
|
||||
*
|
||||
* @return array|mixed
|
||||
* @return array
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
*/
|
||||
class Email_messages {
|
||||
/**
|
||||
* @var EA_Controller
|
||||
* @var EA_Controller|CI_Controller
|
||||
*/
|
||||
protected $CI;
|
||||
protected EA_Controller|CI_Controller $CI;
|
||||
|
||||
/**
|
||||
* Email_messages constructor.
|
||||
|
|
|
@ -22,19 +22,19 @@ use Google\Service\Calendar\Events;
|
|||
*/
|
||||
class Google_sync {
|
||||
/**
|
||||
* @var EA_Controller
|
||||
* @var EA_Controller|CI_Controller
|
||||
*/
|
||||
protected $CI;
|
||||
protected EA_Controller|CI_Controller $CI;
|
||||
|
||||
/**
|
||||
* @var Google_Client
|
||||
*/
|
||||
protected $client;
|
||||
protected Google_Client $client;
|
||||
|
||||
/**
|
||||
* @var Google_Service_Calendar
|
||||
*/
|
||||
protected $service;
|
||||
protected Google_Service_Calendar $service;
|
||||
|
||||
/**
|
||||
* Google_sync constructor.
|
||||
|
@ -57,7 +57,7 @@ class Google_sync {
|
|||
/**
|
||||
* Initialize the client, so that existing execution errors are not passed from one provider to another.
|
||||
*/
|
||||
public function initialize_clients()
|
||||
public function initialize_clients(): void
|
||||
{
|
||||
$http = new GuzzleHttp\Client([
|
||||
'verify' => FALSE
|
||||
|
@ -126,7 +126,7 @@ class Google_sync {
|
|||
* @param string $refresh_token The provider's refresh token. This value is stored in the database and used every
|
||||
* time we need to make actions to his Google Calendar account.
|
||||
*/
|
||||
public function refresh_token(string $refresh_token)
|
||||
public function refresh_token(string $refresh_token): void
|
||||
{
|
||||
$this->initialize_clients();
|
||||
|
||||
|
@ -247,7 +247,7 @@ class Google_sync {
|
|||
* @param array $provider Provider data.
|
||||
* @param string $google_event_id The Google Calendar event ID to be removed.
|
||||
*/
|
||||
public function delete_appointment(array $provider, string $google_event_id)
|
||||
public function delete_appointment(array $provider, string $google_event_id): void
|
||||
{
|
||||
$this->service->events->delete($provider['settings']['google_calendar'], $google_event_id);
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ class Google_sync {
|
|||
* @param array $provider Provider data.
|
||||
* @param string $google_event_id Google Calendar event ID to be removed.
|
||||
*/
|
||||
public function delete_unavailability(array $provider, string $google_event_id)
|
||||
public function delete_unavailability(array $provider, string $google_event_id): void
|
||||
{
|
||||
$this->service->events->delete($provider['settings']['google_calendar'], $google_event_id);
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ use Jsvrcek\ICS\Utility\Formatter;
|
|||
*/
|
||||
class Ics_file {
|
||||
/**
|
||||
* @var EA_Controller
|
||||
* @var EA_Controller|CI_Controller
|
||||
*/
|
||||
protected $CI;
|
||||
protected EA_Controller|CI_Controller $CI;
|
||||
|
||||
/**
|
||||
* Availability constructor.
|
||||
|
|
|
@ -22,9 +22,9 @@ require_once __DIR__ . '/../core/EA_Migration.php';
|
|||
*/
|
||||
class Instance {
|
||||
/**
|
||||
* @var EA_Controller
|
||||
* @var EA_Controller|CI_Controller
|
||||
*/
|
||||
protected $CI;
|
||||
protected EA_Controller|CI_Controller $CI;
|
||||
|
||||
/**
|
||||
* Installation constructor.
|
||||
|
@ -47,7 +47,7 @@ class Instance {
|
|||
*
|
||||
* @param string $type Provide "fresh" to revert previous migrations and start from the beginning or "up"/"down" to step.
|
||||
*/
|
||||
public function migrate(string $type = '')
|
||||
public function migrate(string $type = ''): void
|
||||
{
|
||||
$current_version = $this->CI->migration->current_version();
|
||||
|
||||
|
@ -166,7 +166,7 @@ class Instance {
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function backup(string $path = NULL)
|
||||
public function backup(string $path = NULL): void
|
||||
{
|
||||
$path = $path ?? APPPATH . '/../storage/backups';
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
*/
|
||||
class Notifications {
|
||||
/**
|
||||
* @var EA_Controller
|
||||
* @var EA_Controller|CI_Controller
|
||||
*/
|
||||
protected $CI;
|
||||
protected EA_Controller|CI_Controller $CI;
|
||||
|
||||
/**
|
||||
* Notifications constructor.
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
*/
|
||||
class Permissions {
|
||||
/**
|
||||
* @var EA_Controller
|
||||
* @var EA_Controller|CI_Controller
|
||||
*/
|
||||
protected $CI;
|
||||
protected EA_Controller|CI_Controller $CI;
|
||||
|
||||
/**
|
||||
* Permissions constructor.
|
||||
|
@ -65,12 +65,12 @@ class Permissions {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
if ($role_slug === DB_SLUG_PROVIDER && $limit_customer_access)
|
||||
if ($role_slug === DB_SLUG_PROVIDER)
|
||||
{
|
||||
return $this->CI->appointments_model->query()->where(['id_users_provider' => $user_id, 'id_users_customer' => $customer_id])->get()->num_rows() > 0;
|
||||
}
|
||||
|
||||
if ($role_slug === DB_SLUG_SECRETARY && $limit_customer_access)
|
||||
if ($role_slug === DB_SLUG_SECRETARY)
|
||||
{
|
||||
$secretary = $this->CI->secretaries_model->find($user_id);
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
*/
|
||||
class Synchronization {
|
||||
/**
|
||||
* @var EA_Controller
|
||||
* @var EA_Controller|CI_Controller
|
||||
*/
|
||||
protected $CI;
|
||||
protected EA_Controller|CI_Controller $CI;
|
||||
|
||||
/**
|
||||
* Synchronization constructor.
|
||||
|
@ -45,9 +45,8 @@ class Synchronization {
|
|||
* @param array $provider Provider record.
|
||||
* @param array $customer Customer record.
|
||||
* @param array $settings Required settings for the notification content.
|
||||
* @param bool|false $manage_mode True if the appointment is being edited.
|
||||
*/
|
||||
public function sync_appointment_saved(array $appointment, array $service, array $provider, array $customer, array $settings, bool $manage_mode = FALSE)
|
||||
public function sync_appointment_saved(array $appointment, array $service, array $provider, array $customer, array $settings): void
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -103,7 +102,7 @@ class Synchronization {
|
|||
* @param array $appointment Appointment record.
|
||||
* @param array $provider Provider record.
|
||||
*/
|
||||
public function sync_appointment_deleted(array $appointment, array $provider)
|
||||
public function sync_appointment_deleted(array $appointment, array $provider): void
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -137,7 +136,7 @@ class Synchronization {
|
|||
* @param array $unavailability Unavailability record.
|
||||
* @param array $provider Provider record.
|
||||
*/
|
||||
public function sync_unavailability_saved(array $unavailability, array $provider)
|
||||
public function sync_unavailability_saved(array $unavailability, array $provider): void
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -181,7 +180,7 @@ class Synchronization {
|
|||
* @param array $unavailability Unavailability record.
|
||||
* @param array $provider Provider record.
|
||||
*/
|
||||
public function sync_unavailability_deleted(array $unavailability, array $provider)
|
||||
public function sync_unavailability_deleted(array $unavailability, array $provider): void
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -213,9 +212,9 @@ class Synchronization {
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function remove_appointment_on_provider_change($appointment_id)
|
||||
public function remove_appointment_on_provider_change($appointment_id): void
|
||||
{
|
||||
$existing_appointment = $this->CI->appointments_model->get_row($appointment_id);
|
||||
$existing_appointment = $this->CI->appointments_model->find($appointment_id);
|
||||
|
||||
$existing_google_id = $existing_appointment['id_google_calendar'];
|
||||
|
||||
|
@ -223,7 +222,7 @@ class Synchronization {
|
|||
|
||||
if ( ! empty($existing_google_id) && (int)$existing_provider_id !== (int)$existing_appointment['id_users_provider'])
|
||||
{
|
||||
$existing_provider = $this->CI->providers_model->get_row($existing_provider_id);
|
||||
$existing_provider = $this->CI->providers_model->find($existing_provider_id);
|
||||
|
||||
if ($existing_provider['settings']['google_sync'])
|
||||
{
|
||||
|
|
|
@ -20,19 +20,19 @@
|
|||
*/
|
||||
class Timezones {
|
||||
/**
|
||||
* @var EA_Controller
|
||||
* @var EA_Controller|CI_Controller
|
||||
*/
|
||||
protected $CI;
|
||||
protected EA_Controller|CI_Controller $CI;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $default = 'UTC';
|
||||
protected string $default = 'UTC';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $timezones = [
|
||||
protected array $timezones = [
|
||||
'UTC' => [
|
||||
'UTC' => 'UTC'
|
||||
],
|
||||
|
@ -517,31 +517,17 @@ class Timezones {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_grouped_array()
|
||||
public function to_grouped_array(): array
|
||||
{
|
||||
return $this->timezones;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the session timezone or the default timezone as a fallback.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_session_timezone(): string
|
||||
{
|
||||
$default_timezone = $this->get_default_timezone();
|
||||
|
||||
$timezone = session('timezone');
|
||||
|
||||
return $timezone ?? $default_timezone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default timezone value of the current system.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_timezone()
|
||||
public function get_default_timezone(): string
|
||||
{
|
||||
return 'UTC';
|
||||
}
|
||||
|
@ -557,7 +543,7 @@ class Timezones {
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function convert($value, $from_timezone, $to_timezone)
|
||||
public function convert(string $value, string $from_timezone, string $to_timezone): string
|
||||
{
|
||||
if ( ! $to_timezone || $from_timezone === $to_timezone)
|
||||
{
|
||||
|
@ -582,11 +568,11 @@ class Timezones {
|
|||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function get_timezone_name($value)
|
||||
public function get_timezone_name(string $value): ?string
|
||||
{
|
||||
$timezones = $this->to_array();
|
||||
|
||||
return isset($timezones[$value]) ? $timezones[$value] : NULL;
|
||||
return $timezones[$value] ?? NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -594,7 +580,7 @@ class Timezones {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array()
|
||||
public function to_array(): array
|
||||
{
|
||||
return array_merge(...array_values($this->timezones));
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ use GuzzleHttp\Client;
|
|||
*/
|
||||
class Webhooks_client {
|
||||
/**
|
||||
* @var EA_Controller
|
||||
* @var EA_Controller|CI_Controller
|
||||
*/
|
||||
protected $CI;
|
||||
protected EA_Controller|CI_Controller $CI;
|
||||
|
||||
/**
|
||||
* Webhook client constructor.
|
||||
|
@ -56,7 +56,7 @@ class Webhooks_client {
|
|||
|
||||
foreach ($webhooks as $webhook)
|
||||
{
|
||||
if (strpos($webhook['actions'], $action) !== FALSE)
|
||||
if (str_contains($webhook['actions'], $action))
|
||||
{
|
||||
$this->call($webhook, $action, $payload);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class Webhooks_client {
|
|||
* @param string $action
|
||||
* @param array $payload
|
||||
*/
|
||||
private function call(array $webhook, string $action, array $payload)
|
||||
private function call(array $webhook, string $action, array $payload): void
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ class Admins_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
'id_roles' => 'integer',
|
||||
];
|
||||
|
@ -30,7 +30,7 @@ class Admins_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $api_resource = [
|
||||
protected array $api_resource = [
|
||||
'id' => 'id',
|
||||
'firstName' => 'first_name',
|
||||
'lastName' => 'last_name',
|
||||
|
@ -55,6 +55,7 @@ class Admins_model extends EA_Model {
|
|||
* @return int Returns the admin ID.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save(array $admin): int
|
||||
{
|
||||
|
@ -153,7 +154,7 @@ class Admins_model extends EA_Model {
|
|||
->where('roles.slug', DB_SLUG_ADMIN)
|
||||
->where('users.email', $admin['email'])
|
||||
->where('users.id !=', $admin_id)
|
||||
->where('users.delete_datetime', NULL)
|
||||
->where('users.delete_datetime')
|
||||
->get()
|
||||
->num_rows();
|
||||
|
||||
|
@ -194,7 +195,7 @@ class Admins_model extends EA_Model {
|
|||
*
|
||||
* @return int Returns the admin ID.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws RuntimeException|Exception
|
||||
*/
|
||||
protected function insert(array $admin): int
|
||||
{
|
||||
|
@ -231,6 +232,7 @@ class Admins_model extends EA_Model {
|
|||
* @return int Returns the admin ID.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function update(array $admin): int
|
||||
{
|
||||
|
@ -378,7 +380,7 @@ class Admins_model extends EA_Model {
|
|||
/**
|
||||
* Get all admins that match the provided criteria.
|
||||
*
|
||||
* @param array|string $where Where conditions.
|
||||
* @param array|string|null $where Where conditions.
|
||||
* @param int|null $limit Record limit.
|
||||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
|
@ -386,7 +388,7 @@ class Admins_model extends EA_Model {
|
|||
*
|
||||
* @return array Returns an array of admins.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
{
|
||||
$role_id = $this->get_admin_role_id();
|
||||
|
||||
|
@ -474,9 +476,9 @@ class Admins_model extends EA_Model {
|
|||
*
|
||||
* @param int $admin_id Admin ID.
|
||||
* @param string $name Setting name.
|
||||
* @param mixed $value Setting value.
|
||||
* @param mixed|null $value Setting value.
|
||||
*/
|
||||
public function set_setting(int $admin_id, string $name, $value = NULL)
|
||||
public function set_setting(int $admin_id, string $name, mixed $value = NULL)
|
||||
{
|
||||
if ( ! $this->db->update('user_settings', [$name => $value], ['id_users' => $admin_id]))
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@ class Appointments_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
'is_unavailability' => 'boolean',
|
||||
'id_users_provider' => 'integer',
|
||||
|
@ -31,7 +31,7 @@ class Appointments_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $api_resource = [
|
||||
protected array $api_resource = [
|
||||
'id' => 'id',
|
||||
'book' => 'book_datetime',
|
||||
'start' => 'start_datetime',
|
||||
|
@ -306,7 +306,7 @@ class Appointments_model extends EA_Model {
|
|||
/**
|
||||
* Get all appointments that match the provided criteria.
|
||||
*
|
||||
* @param array|string $where Where conditions.
|
||||
* @param array|string|null $where Where conditions.
|
||||
* @param int|null $limit Record limit.
|
||||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
|
@ -314,7 +314,7 @@ class Appointments_model extends EA_Model {
|
|||
*
|
||||
* @return array Returns an array of appointments.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
{
|
||||
if ($where !== NULL)
|
||||
{
|
||||
|
|
|
@ -22,14 +22,14 @@ class Categories_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $api_resource = [
|
||||
protected array $api_resource = [
|
||||
'id' => 'id',
|
||||
'name' => 'name',
|
||||
'description' => 'description',
|
||||
|
@ -225,7 +225,7 @@ class Categories_model extends EA_Model {
|
|||
/**
|
||||
* Get all services that match the provided criteria.
|
||||
*
|
||||
* @param array|string $where Where conditions
|
||||
* @param array|string|null $where Where conditions
|
||||
* @param int|null $limit Record limit.
|
||||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
|
@ -233,7 +233,7 @@ class Categories_model extends EA_Model {
|
|||
*
|
||||
* @return array Returns an array of service categories.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
{
|
||||
if ($where !== NULL)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ class Consents_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
];
|
||||
|
||||
|
@ -130,7 +130,7 @@ class Consents_model extends EA_Model {
|
|||
}
|
||||
else
|
||||
{
|
||||
return $this->db->update('consents', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $consent_id]);
|
||||
$this->db->update('consents', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $consent_id]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ class Consents_model extends EA_Model {
|
|||
/**
|
||||
* Get all consents that match the provided criteria.
|
||||
*
|
||||
* @param array|string $where Where conditions.
|
||||
* @param array|string|null $where Where conditions.
|
||||
* @param int|null $limit Record limit.
|
||||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
|
@ -215,7 +215,7 @@ class Consents_model extends EA_Model {
|
|||
*
|
||||
* @return array Returns an array of consents.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
{
|
||||
if ($where !== NULL)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ class Customers_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
'id_roles' => 'integer',
|
||||
];
|
||||
|
@ -30,7 +30,7 @@ class Customers_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $api_resource = [
|
||||
protected array $api_resource = [
|
||||
'id' => 'id',
|
||||
'firstName' => 'first_name',
|
||||
'lastName' => 'last_name',
|
||||
|
@ -133,7 +133,7 @@ class Customers_model extends EA_Model {
|
|||
->select()
|
||||
->from('users')
|
||||
->join('roles', 'roles.id = users.id_roles', 'inner')
|
||||
->where('users.delete_datetime', NULL)
|
||||
->where('users.delete_datetime')
|
||||
->where('roles.slug', DB_SLUG_CUSTOMER)
|
||||
->where('users.email', $customer['email'])
|
||||
->where('users.id !=', $customer_id)
|
||||
|
@ -285,7 +285,7 @@ class Customers_model extends EA_Model {
|
|||
/**
|
||||
* Get all customers that match the provided criteria.
|
||||
*
|
||||
* @param array|string $where Where conditions.
|
||||
* @param array|string|null $where Where conditions.
|
||||
* @param int|null $limit Record limit.
|
||||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
|
@ -293,7 +293,7 @@ class Customers_model extends EA_Model {
|
|||
*
|
||||
* @return array Returns an array of customers.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
{
|
||||
$role_id = $this->get_customer_role_id();
|
||||
|
||||
|
@ -361,7 +361,7 @@ class Customers_model extends EA_Model {
|
|||
->from('users')
|
||||
->join('roles', 'roles.id = users.id_roles', 'inner')
|
||||
->where('users.email', $customer['email'])
|
||||
->where('users.delete_datetime', NULL)
|
||||
->where('users.delete_datetime')
|
||||
->where('roles.slug', DB_SLUG_CUSTOMER)
|
||||
->get()
|
||||
->num_rows();
|
||||
|
@ -391,7 +391,7 @@ class Customers_model extends EA_Model {
|
|||
->from('users')
|
||||
->join('roles', 'roles.id = users.id_roles', 'inner')
|
||||
->where('users.email', $customer['email'])
|
||||
->where('users.delete_datetime', NULL)
|
||||
->where('users.delete_datetime')
|
||||
->where('roles.slug', DB_SLUG_CUSTOMER)
|
||||
->get()
|
||||
->row_array();
|
||||
|
|
|
@ -22,7 +22,7 @@ class Providers_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
'is_private' => 'boolean',
|
||||
'id_roles' => 'integer',
|
||||
|
@ -31,7 +31,7 @@ class Providers_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $api_resource = [
|
||||
protected array $api_resource = [
|
||||
'id' => 'id',
|
||||
'firstName' => 'first_name',
|
||||
'lastName' => 'last_name',
|
||||
|
@ -57,6 +57,7 @@ class Providers_model extends EA_Model {
|
|||
* @return int Returns the provider ID.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save(array $provider): int
|
||||
{
|
||||
|
@ -168,7 +169,7 @@ class Providers_model extends EA_Model {
|
|||
->where('roles.slug', DB_SLUG_PROVIDER)
|
||||
->where('users.email', $provider['email'])
|
||||
->where('users.id !=', $provider_id)
|
||||
->where('users.delete_datetime', NULL)
|
||||
->where('users.delete_datetime')
|
||||
->get()
|
||||
->num_rows();
|
||||
|
||||
|
@ -209,7 +210,7 @@ class Providers_model extends EA_Model {
|
|||
*
|
||||
* @return int Returns the provider ID.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws RuntimeException|Exception
|
||||
*/
|
||||
protected function insert(array $provider): int
|
||||
{
|
||||
|
@ -248,7 +249,7 @@ class Providers_model extends EA_Model {
|
|||
*
|
||||
* @return int Returns the provider ID.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws RuntimeException|Exception
|
||||
*/
|
||||
protected function update(array $provider): int
|
||||
{
|
||||
|
@ -398,7 +399,7 @@ class Providers_model extends EA_Model {
|
|||
/**
|
||||
* Get all providers that match the provided criteria.
|
||||
*
|
||||
* @param array|string $where Where conditions
|
||||
* @param array|string|null $where Where conditions
|
||||
* @param int|null $limit Record limit.
|
||||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
|
@ -406,7 +407,7 @@ class Providers_model extends EA_Model {
|
|||
*
|
||||
* @return array Returns an array of providers.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
{
|
||||
$role_id = $this->get_provider_role_id();
|
||||
|
||||
|
@ -519,9 +520,9 @@ class Providers_model extends EA_Model {
|
|||
*
|
||||
* @param int $provider_id Provider ID.
|
||||
* @param string $name Setting name.
|
||||
* @param mixed $value Setting value.
|
||||
* @param mixed|null $value Setting value.
|
||||
*/
|
||||
public function set_setting(int $provider_id, string $name, $value = NULL)
|
||||
public function set_setting(int $provider_id, string $name, mixed $value = NULL)
|
||||
{
|
||||
if ( ! $this->db->update('user_settings', [$name => $value], ['id_users' => $provider_id]))
|
||||
{
|
||||
|
@ -579,6 +580,7 @@ class Providers_model extends EA_Model {
|
|||
* @param array $working_plan_exception Associative array with the working plan exception data.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save_working_plan_exception(int $provider_id, string $date, array $working_plan_exception)
|
||||
{
|
||||
|
@ -793,22 +795,18 @@ class Providers_model extends EA_Model {
|
|||
|
||||
foreach ($resources as $resource)
|
||||
{
|
||||
switch ($resource)
|
||||
$provider['services'] = match ($resource)
|
||||
{
|
||||
case 'services':
|
||||
$provider['services'] = $this
|
||||
->db
|
||||
->select('services.*')
|
||||
->from('services')
|
||||
->join('services_providers', 'services_providers.id_services = services.id', 'inner')
|
||||
->where('id_users', $provider['id'])
|
||||
->get()
|
||||
->result_array();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InvalidArgumentException('The requested provider relation is not supported: ' . $resource);
|
||||
}
|
||||
'services' => $this
|
||||
->db
|
||||
->select('services.*')
|
||||
->from('services')
|
||||
->join('services_providers', 'services_providers.id_services = services.id', 'inner')
|
||||
->where('id_users', $provider['id'])
|
||||
->get()
|
||||
->result_array(),
|
||||
default => throw new InvalidArgumentException('The requested provider relation is not supported: ' . $resource),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class Roles_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
'is_admin' => 'boolean',
|
||||
'appointments' => 'integer',
|
||||
|
@ -223,7 +223,7 @@ class Roles_model extends EA_Model {
|
|||
/**
|
||||
* Get all roles that match the provided criteria.
|
||||
*
|
||||
* @param array|string $where Where conditions
|
||||
* @param array|string|null $where Where conditions
|
||||
* @param int|null $limit Record limit.
|
||||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
|
@ -231,7 +231,7 @@ class Roles_model extends EA_Model {
|
|||
*
|
||||
* @return array Returns an array of roles.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
{
|
||||
if ($where !== NULL)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ class Secretaries_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
'id_roles' => 'integer',
|
||||
];
|
||||
|
@ -30,7 +30,7 @@ class Secretaries_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $api_resource = [
|
||||
protected array $api_resource = [
|
||||
'id' => 'id',
|
||||
'firstName' => 'first_name',
|
||||
'lastName' => 'last_name',
|
||||
|
@ -55,6 +55,7 @@ class Secretaries_model extends EA_Model {
|
|||
* @return int Returns the secretary ID.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save(array $secretary): int
|
||||
{
|
||||
|
@ -166,7 +167,7 @@ class Secretaries_model extends EA_Model {
|
|||
->where('roles.slug', DB_SLUG_SECRETARY)
|
||||
->where('users.email', $secretary['email'])
|
||||
->where('users.id !=', $secretary_id)
|
||||
->where('users.delete_datetime', NULL)
|
||||
->where('users.delete_datetime')
|
||||
->get()
|
||||
->num_rows();
|
||||
|
||||
|
@ -207,7 +208,7 @@ class Secretaries_model extends EA_Model {
|
|||
*
|
||||
* @return int Returns the secretary ID.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws RuntimeException|Exception
|
||||
*/
|
||||
protected function insert(array $secretary): int
|
||||
{
|
||||
|
@ -247,7 +248,7 @@ class Secretaries_model extends EA_Model {
|
|||
*
|
||||
* @return int Returns the secretary ID.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws RuntimeException|Exception
|
||||
*/
|
||||
protected function update(array $secretary): int
|
||||
{
|
||||
|
@ -393,7 +394,7 @@ class Secretaries_model extends EA_Model {
|
|||
/**
|
||||
* Get all secretaries that match the provided criteria.
|
||||
*
|
||||
* @param array|string $where Where conditions
|
||||
* @param array|string|null $where Where conditions
|
||||
* @param int|null $limit Record limit.
|
||||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
|
@ -401,7 +402,7 @@ class Secretaries_model extends EA_Model {
|
|||
*
|
||||
* @return array Returns an array of secretaries.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
{
|
||||
$role_id = $this->get_secretary_role_id();
|
||||
|
||||
|
@ -496,9 +497,9 @@ class Secretaries_model extends EA_Model {
|
|||
*
|
||||
* @param int $secretary_id Secretary ID.
|
||||
* @param string $name Setting name.
|
||||
* @param mixed $value Setting value.
|
||||
* @param mixed|null $value Setting value.
|
||||
*/
|
||||
public function set_setting(int $secretary_id, string $name, $value = NULL)
|
||||
public function set_setting(int $secretary_id, string $name, mixed $value = NULL)
|
||||
{
|
||||
if ( ! $this->db->update('user_settings', [$name => $value], ['id_users' => $secretary_id]))
|
||||
{
|
||||
|
@ -644,22 +645,18 @@ class Secretaries_model extends EA_Model {
|
|||
|
||||
foreach ($resources as $resource)
|
||||
{
|
||||
switch ($resource)
|
||||
$secretary['providers'] = match ($resource)
|
||||
{
|
||||
case 'providers':
|
||||
$secretary['providers'] = $this
|
||||
->db
|
||||
->select('users.*')
|
||||
->from('users')
|
||||
->join('secretaries_providers', 'secretaries_providers.id_users_provider = users.id', 'inner')
|
||||
->where('id_users_secretary', $secretary['id'])
|
||||
->get()
|
||||
->result_array();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InvalidArgumentException('The requested secretary relation is not supported: ' . $resource);
|
||||
}
|
||||
'providers' => $this
|
||||
->db
|
||||
->select('users.*')
|
||||
->from('users')
|
||||
->join('secretaries_providers', 'secretaries_providers.id_users_provider = users.id', 'inner')
|
||||
->where('id_users_secretary', $secretary['id'])
|
||||
->get()
|
||||
->result_array(),
|
||||
default => throw new InvalidArgumentException('The requested secretary relation is not supported: ' . $resource),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class Services_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
'price' => 'float',
|
||||
'attendants_number' => 'integer',
|
||||
|
@ -33,7 +33,7 @@ class Services_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $api_resource = [
|
||||
protected array $api_resource = [
|
||||
'id' => 'id',
|
||||
'name' => 'name',
|
||||
'duration' => 'duration',
|
||||
|
@ -281,7 +281,7 @@ class Services_model extends EA_Model {
|
|||
/**
|
||||
* Get all services that match the provided criteria.
|
||||
*
|
||||
* @param array|string $where Where conditions
|
||||
* @param array|string|null $where Where conditions
|
||||
* @param int|null $limit Record limit.
|
||||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
|
@ -289,7 +289,7 @@ class Services_model extends EA_Model {
|
|||
*
|
||||
* @return array Returns an array of services.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
{
|
||||
if ($where !== NULL)
|
||||
{
|
||||
|
@ -417,20 +417,16 @@ class Services_model extends EA_Model {
|
|||
|
||||
foreach ($resources as $resource)
|
||||
{
|
||||
switch ($resource)
|
||||
$service['category'] = match ($resource)
|
||||
{
|
||||
case 'category':
|
||||
$service['category'] = $this
|
||||
->db
|
||||
->get_where('categories', [
|
||||
'id' => $service['id_categories'] ?? $service['categoryId'] ?? NULL
|
||||
])
|
||||
->row_array();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InvalidArgumentException('The requested appointment relation is not supported: ' . $resource);
|
||||
}
|
||||
'category' => $this
|
||||
->db
|
||||
->get_where('categories', [
|
||||
'id' => $service['id_categories'] ?? $service['categoryId'] ?? NULL
|
||||
])
|
||||
->row_array(),
|
||||
default => throw new InvalidArgumentException('The requested appointment relation is not supported: ' . $resource),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,14 +22,14 @@ class Settings_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $api_resource = [
|
||||
protected array $api_resource = [
|
||||
'name' => 'name',
|
||||
'value' => 'value',
|
||||
];
|
||||
|
@ -224,7 +224,7 @@ class Settings_model extends EA_Model {
|
|||
/**
|
||||
* Get all settings that match the provided criteria.
|
||||
*
|
||||
* @param array|string $where Where conditions
|
||||
* @param array|string|null $where Where conditions
|
||||
* @param int|null $limit Record limit.
|
||||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
|
@ -232,7 +232,7 @@ class Settings_model extends EA_Model {
|
|||
*
|
||||
* @return array Returns an array of settings.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
{
|
||||
if ($where !== NULL)
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@ class Unavailabilities_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
'is_unavailability' => 'boolean',
|
||||
'id_users_provider' => 'integer',
|
||||
|
@ -31,7 +31,7 @@ class Unavailabilities_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $api_resource = [
|
||||
protected array $api_resource = [
|
||||
'id' => 'id',
|
||||
'book' => 'book_datetime',
|
||||
'start' => 'start_datetime',
|
||||
|
@ -275,7 +275,7 @@ class Unavailabilities_model extends EA_Model {
|
|||
/**
|
||||
* Get all unavailabilities that match the provided criteria.
|
||||
*
|
||||
* @param array|string $where Where conditions.
|
||||
* @param array|string|null $where Where conditions.
|
||||
* @param int|null $limit Record limit.
|
||||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
|
@ -283,7 +283,7 @@ class Unavailabilities_model extends EA_Model {
|
|||
*
|
||||
* @return array Returns an array of unavailabilities.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
{
|
||||
if ($where !== NULL)
|
||||
{
|
||||
|
@ -386,20 +386,16 @@ class Unavailabilities_model extends EA_Model {
|
|||
|
||||
foreach ($resources as $resource)
|
||||
{
|
||||
switch ($resource)
|
||||
$unavailability['provider'] = match ($resource)
|
||||
{
|
||||
case 'provider':
|
||||
$unavailability['provider'] = $this
|
||||
->db
|
||||
->get_where('users', [
|
||||
'id' => $unavailability['id_users_provider'] ?? $unavailability['providerId'] ?? NULL
|
||||
])
|
||||
->row_array();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InvalidArgumentException('The requested unavailability relation is not supported: ' . $resource);
|
||||
}
|
||||
'provider' => $this
|
||||
->db
|
||||
->get_where('users', [
|
||||
'id' => $unavailability['id_users_provider'] ?? $unavailability['providerId'] ?? NULL
|
||||
])
|
||||
->row_array(),
|
||||
default => throw new InvalidArgumentException('The requested unavailability relation is not supported: ' . $resource),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class Users_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
'id_roles' => 'integer',
|
||||
];
|
||||
|
@ -30,7 +30,7 @@ class Users_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $api_resource = [
|
||||
protected array $api_resource = [
|
||||
'id' => 'id',
|
||||
'firstName' => 'first_name',
|
||||
'lastName' => 'last_name',
|
||||
|
@ -55,6 +55,7 @@ class Users_model extends EA_Model {
|
|||
* @return int Returns the user ID.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save(array $user): int
|
||||
{
|
||||
|
@ -109,7 +110,7 @@ class Users_model extends EA_Model {
|
|||
*
|
||||
* @return int Returns the user ID.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws RuntimeException|Exception
|
||||
*/
|
||||
protected function insert(array $user): int
|
||||
{
|
||||
|
@ -140,7 +141,7 @@ class Users_model extends EA_Model {
|
|||
*
|
||||
* @return int Returns the user ID.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws RuntimeException|Exception
|
||||
*/
|
||||
protected function update(array $user): int
|
||||
{
|
||||
|
@ -274,7 +275,7 @@ class Users_model extends EA_Model {
|
|||
/**
|
||||
* Get all users that match the provided criteria.
|
||||
*
|
||||
* @param array|string $where Where conditions
|
||||
* @param array|string|null $where Where conditions
|
||||
* @param int|null $limit Record limit.
|
||||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
|
@ -282,7 +283,7 @@ class Users_model extends EA_Model {
|
|||
*
|
||||
* @return array Returns an array of users.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
{
|
||||
if ($where !== NULL)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ class Webhooks_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
'is_ssl_verified' => 'boolean',
|
||||
|
@ -31,7 +31,7 @@ class Webhooks_model extends EA_Model {
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $api_resource = [
|
||||
protected array $api_resource = [
|
||||
'id' => 'id',
|
||||
'name' => 'name',
|
||||
'url' => 'url',
|
||||
|
@ -222,7 +222,7 @@ class Webhooks_model extends EA_Model {
|
|||
/**
|
||||
* Get all webhooks that match the provided criteria.
|
||||
*
|
||||
* @param array|string $where Where conditions.
|
||||
* @param array|string|null $where Where conditions.
|
||||
* @param int|null $limit Record limit.
|
||||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
|
@ -230,7 +230,7 @@ class Webhooks_model extends EA_Model {
|
|||
*
|
||||
* @return array Returns an array of webhooks.
|
||||
*/
|
||||
public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array
|
||||
{
|
||||
if ($where !== NULL)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue