diff --git a/config/core.php b/config/core.php index 7b2e360..2a6e5ed 100644 --- a/config/core.php +++ b/config/core.php @@ -3,26 +3,26 @@ return [ /* -|-------------------------------------------------------------------------- -| User Model Definition -|-------------------------------------------------------------------------- -| -| Please specify a user model that should be used to setup `creator` -| and `updater` relationship. -| -*/ + |-------------------------------------------------------------------------- + | User Model Definition + |-------------------------------------------------------------------------- + | + | Please specify a user model that should be used to setup `creator` + | and `updater` relationship. + | + */ 'paginate_location' => 'layouts.paginate.', /* -|-------------------------------------------------------------------------- -| User Model Definition -|-------------------------------------------------------------------------- -| -| Please specify a user model that should be used to setup `creator` -| and `updater` relationship. -| -*/ + |-------------------------------------------------------------------------- + | User Model Definition + |-------------------------------------------------------------------------- + | + | Please specify a user model that should be used to setup `creator` + | and `updater` relationship. + | + */ 'popup_actions' => [ 'delete' => 'core::popup.delete', @@ -30,6 +30,9 @@ 'export' => 'core::popup.export', 'import' => 'core::popup.import', ], + + //Blameable Trait and Uses + 'blame' => [ /* @@ -81,4 +84,23 @@ 'deletedBy' => 'deleted_by', ], + + //XML Response handler + 'xml' => [ + /* + |-------------------------------------------------------------------------- + | Default template + |-------------------------------------------------------------------------- + | + | Template to XML + | + | + | + */ + 'template' => '', + 'caseSensitive' => false, + 'showEmptyField' => true, //Show empty field + 'charset' => 'utf-8', + 'rowName' => null, + ] ]; diff --git a/config/xml.php b/config/xml.php deleted file mode 100644 index efe5e30..0000000 --- a/config/xml.php +++ /dev/null @@ -1,27 +0,0 @@ - - | - */ - 'template' => '', - 'caseSensitive' => false, - 'showEmptyField' => true, //Show empty field - 'charset' => 'utf-8', - - /** - * line name if it is an array - * - * example - * value null = - * value name item = - */ - 'rowName' => null, -]; diff --git a/src/CoreServiceProvider.php b/src/CoreServiceProvider.php index d046195..87bef04 100644 --- a/src/CoreServiceProvider.php +++ b/src/CoreServiceProvider.php @@ -20,7 +20,6 @@ public function boot() //config $this->publishes([ __DIR__.'/../config/core.php' => config_path('core.php'), - __DIR__.'/../config/xml.php' => config_path('xml.php'), __DIR__.'/../config/audit.php' => config_path('audit.php'), __DIR__.'/../config/media-library.php' => config_path('media-library.php'), __DIR__.'/../config/columnsortable.php' => config_path('columnsortable.php'), @@ -62,10 +61,6 @@ public function register() $this->mergeConfigFrom( __DIR__.'/../config/core.php', 'core' ); - - $this->mergeConfigFrom( - __DIR__.'/../config/xml.php', 'xml' - ); } private function loadMacro() diff --git a/src/Http/Response/XmlResponse.php b/src/Http/Response/XmlResponse.php index 8e5cf94..2d1bf5a 100644 --- a/src/Http/Response/XmlResponse.php +++ b/src/Http/Response/XmlResponse.php @@ -15,27 +15,27 @@ class XmlResponse /** * @var bool */ - private $caseSensitive; + private $caseSensitive = false; /** * @var string */ - private $template; + private $template = ''; /** * @var bool */ - private $showEmptyField; + private $showEmptyField = true; /** * @var string */ - private $charset; + private $charset = 'utf-8'; /** * @var mixed */ - private $rowName; + private $rowName = null; /** * @var bool @@ -47,11 +47,7 @@ class XmlResponse */ public function __construct() { - $this->caseSensitive = Config::get('xml.caseSensitive'); - $this->template = Config::get('xml.template'); - $this->showEmptyField = Config::get('xml.showEmptyField'); - $this->charset = Config::get('xml.charset'); - $this->rowName = Config::get('xml.rowName'); + $this->config(Config::get('core.xml')); } /** @@ -65,14 +61,14 @@ private function header() } /** - * @param array $header + * @param array $header * @return string */ private function charset($header = []): string { $charset = 'application/xml; '; - if (! empty($this->charset)) { + if (!empty($this->charset)) { $charset .= "charset={$this->charset}"; } @@ -84,13 +80,13 @@ private function charset($header = []): string */ private function encodingXml() { - if (! empty($this->charset) && strpos($this->template, 'encoding') === false) { + if (!empty($this->charset) && strpos($this->template, 'encoding') === false) { $this->template = "charset}\"?>{$this->template}"; } } /** - * @param string $value + * @param string $value * @return bool */ private function isType(string $value): bool @@ -119,11 +115,11 @@ private function caseSensitive($value) private function rowName($row) { - if (! empty($this->rowName)) { + if (!empty($this->rowName)) { return $this->rowName; } - return 'row_'.$row; + return 'row_' . $row; } /** @@ -144,7 +140,7 @@ private function isConfig($value): bool /** * replaces the current setting * - * @param array $config + * @param array $config * @return void */ private function config($config = []) @@ -158,9 +154,9 @@ private function config($config = []) /** * @param $array - * @param bool $xml - * @param array $config - * @param int $status + * @param bool $xml + * @param array $config + * @param int $status * @return mixed * * @throws XmlResponseException @@ -172,7 +168,7 @@ public function array2xml($array, $xml = false, $config = [], $status = 200) $array = $array->toArray(); } - if (! $this->isType(gettype($array))) { + if (!$this->isType(gettype($array))) { throw new XmlResponseException('It is not possible to convert data to XML Response'); } @@ -193,7 +189,7 @@ public function array2xml($array, $xml = false, $config = [], $status = 200) } elseif (is_object($value)) { $this->array2xml($value, $xml->addChild($this->caseSensitive((new \ReflectionClass(get_class($value)))->getShortName()))); } else { - if (! is_null($value) || $this->showEmptyField) { + if (!is_null($value) || $this->showEmptyField) { if (is_numeric($key)) { $xml->addChild($this->caseSensitive($this->rowName($key)), htmlspecialchars($value)); } else { @@ -211,8 +207,8 @@ public function array2xml($array, $xml = false, $config = [], $status = 200) } /** - * @param array $array - * @param array $config + * @param array $array + * @param array $config * @return string * * @throws XmlResponseException diff --git a/src/Supports/Constant.php b/src/Supports/Constant.php index 058ac22..1c78be6 100644 --- a/src/Supports/Constant.php +++ b/src/Supports/Constant.php @@ -12,31 +12,11 @@ class Constant */ public const ENABLED_OPTIONS = ['yes' => 'Yes', 'no' => 'No']; - /** - * System Model Status - */ - public const GUEST_ROLE_ID = 4; - - /** - * System User Permission Guards - */ - public const PERMISSION_GUARDS = ['web' => 'WEB']; - - /** - * System User Permission Guard - */ - public const PERMISSION_GUARD = 'web'; - /** * System Permission Title Constraint */ public const PERMISSION_NAME_ALLOW_CHAR = '([a-zA-Z0-9.-_]+)'; - /** - * Keyword to purge Soft Deleted Models - */ - public const PURGE_MODEL_QSA = 'purge'; - /** * Timing Constants */ @@ -59,13 +39,13 @@ class Constant /** * Toastr Message Levels */ - public const MSG_TOASTR_ERROR = 'error'; + public const MESSAGE_ERROR = 'error'; - public const MSG_TOASTR_WARNING = 'warning'; + public const MESSAGE_WARNING = 'warning'; - public const MSG_TOASTR_SUCCESS = 'success'; + public const MESSAGE_SUCCESS = 'success'; - public const MSG_TOASTR_INFO = 'info'; + public const MESSAGE_INFO = 'info'; /** * Authentication Login Medium @@ -88,7 +68,7 @@ class Constant public const EXPORT_OPTIONS = [ 'xlsx' => 'Microsoft Excel (.xlsx)', 'ods' => 'Open Document Spreadsheet (.ods)', - 'csv' => 'Comma Seperated Values (.csv)', + 'csv' => 'Comma Separated Values (.csv)', ]; /** @@ -132,38 +112,4 @@ class Constant * Default Exp[ort type */ public const EXPORT_DEFAULT = 'xlsx'; - - /** - * CATALOG TYPES - */ - public const CATALOG_TYPE = [ - 'GENDER' => 'GEN', - 'MARITAL_STATUS' => 'MAS', - 'RELIGION' => 'REL', - 'UNIVERSITY' => 'UNI', - 'BOARD' => 'BOR', - 'QUOTA' => 'QOT', - ]; - - /** - * CATALOG TYPES - */ - public const CATALOG_LABEL = [ - 'GEN' => 'Gender', - 'MAS' => 'Marital Status', - 'REL' => 'Religion', - 'UNI' => 'University', - 'BOR' => 'Board', - 'QOT' => 'Quote', - ]; - - public const GPA_TYPE = [ - 1 => '1st Division', - 2 => '2nd Division', - 3 => '3rd Division', - 4 => 'GPA(Out of 4)', - 5 => 'GPA(Out of 5)', - 6 => 'Others', - - ]; }