@@ -17,11 +17,11 @@ |
||
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | - * @property mixed $meta_keywords |
|
| 21 | - * @property mixed $meta_description |
|
| 22 | - * @property mixed $page_js |
|
| 23 | - * @property mixed $page_css |
|
| 24 | - */ |
|
| 20 | + * @property mixed $meta_keywords |
|
| 21 | + * @property mixed $meta_description |
|
| 22 | + * @property mixed $page_js |
|
| 23 | + * @property mixed $page_css |
|
| 24 | + */ |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | class Datastore{ |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | 26 | |
| 27 | -class Datastore{ |
|
| 27 | +class Datastore { |
|
| 28 | 28 | |
| 29 | - protected $__asset = false; |
|
| 30 | - protected $__asset_properties = []; |
|
| 31 | - protected $__value_equals = null; |
|
| 32 | - protected $__status_equals = false; |
|
| 33 | - protected $__start_date = null; |
|
| 34 | - protected $__end_date = null; |
|
| 29 | + protected $__asset = false; |
|
| 30 | + protected $__asset_properties = []; |
|
| 31 | + protected $__value_equals = null; |
|
| 32 | + protected $__status_equals = false; |
|
| 33 | + protected $__start_date = null; |
|
| 34 | + protected $__end_date = null; |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * |
@@ -64,17 +64,17 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $this->__model = DatastoreModel::findOrFail($id); |
| 66 | 66 | |
| 67 | - if(!$this->__model){ |
|
| 67 | + if (!$this->__model) { |
|
| 68 | 68 | //could not load <div class="">thr</div> |
| 69 | 69 | throw new DatastoreException("Record not found"); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | foreach ($this->__model->toArray() as $k => $v) |
| 73 | 73 | { |
| 74 | - if($k === 'options' || $k === 'meta'){ |
|
| 74 | + if ($k === 'options' || $k === 'meta') { |
|
| 75 | 75 | $v = json_decode($v, true); |
| 76 | 76 | } |
| 77 | - if(in_array($k, ['created_at','updated_at','date_start','date_end'])){ |
|
| 77 | + if (in_array($k, ['created_at', 'updated_at', 'date_start', 'date_end'])) { |
|
| 78 | 78 | $v = Carbon::parse($v); |
| 79 | 79 | } |
| 80 | 80 | $this->{$k} = $v; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $this->ownDatastore[] = self::getAssetById($ds->id); |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | - }else{ |
|
| 92 | + }else { |
|
| 93 | 93 | $this->__model = new DatastoreModel(); |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -101,23 +101,23 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return void |
| 103 | 103 | */ |
| 104 | - public static function getAssetById($id){ |
|
| 104 | + public static function getAssetById($id) { |
|
| 105 | 105 | $datastore = new self($id); |
| 106 | 106 | $datastore->setAssetType($datastore->type); |
| 107 | 107 | return $datastore; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public static function find($id){ |
|
| 111 | - if(!is_array($id)){ |
|
| 112 | - if(is_object($id)){ |
|
| 110 | + public static function find($id) { |
|
| 111 | + if (!is_array($id)) { |
|
| 112 | + if (is_object($id)) { |
|
| 113 | 113 | return self::getAssetById($id->id); |
| 114 | 114 | } |
| 115 | 115 | return self::getAssetById($id); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if(is_array($id)){ |
|
| 118 | + if (is_array($id)) { |
|
| 119 | 119 | $assets = []; |
| 120 | - foreach($id as $i){ |
|
| 120 | + foreach ($id as $i) { |
|
| 121 | 121 | $assets[] = self::getAssetById($i); |
| 122 | 122 | } |
| 123 | 123 | return $assets; |
@@ -138,8 +138,8 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | |
| 141 | - public function ownDatastore(){ |
|
| 142 | - return ($this->ownDatastore)?$this->ownDatastore: array(); |
|
| 141 | + public function ownDatastore() { |
|
| 142 | + return ($this->ownDatastore) ? $this->ownDatastore : array(); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -200,9 +200,9 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | if (!isset($this->__asset_properties[$p])) |
| 202 | 202 | { |
| 203 | - $this->__asset_properties[$p]['temp'] = self::getAsset($this->__asset->properties[$p]['type']); |
|
| 203 | + $this->__asset_properties[$p]['temp'] = self::getAsset($this->__asset->properties[$p]['type']); |
|
| 204 | 204 | $this->__asset_properties[$p]['temp']->name = (isset($this->__asset->properties[$p]['name'])) ? $this->__asset->properties[$p]['name'] : null; |
| 205 | - $this->__asset_properties[$p]['temp']->key = $p; |
|
| 205 | + $this->__asset_properties[$p]['temp']->key = $p; |
|
| 206 | 206 | $this->__asset_properties[$p]['temp']->private = (isset($this->__asset->properties[$p]['private'])) ? $this->__asset->properties[$p]['private'] : false; // accessibility |
| 207 | 207 | $this->__asset_properties[$p]['temp']->value = (isset($this->__asset->properties[$p]['value'])) ? $this->__asset->properties[$p]['value'] : null; // the actual value of the property |
| 208 | 208 | $this->__asset_properties[$p]['temp']->options = (isset($this->__asset->properties[$p]['options'])) ? $this->__asset->properties[$p]['options'] : null; // additional options specific to the property |
@@ -211,8 +211,8 @@ discard block |
||
| 211 | 211 | $this->__asset_properties[$p]['temp']->help = (isset($this->__asset->properties[$p]['help'])) ? $this->__asset->properties[$p]['help'] : null; // additional options specific to the property |
| 212 | 212 | $this->__asset_properties[$p]['temp']->required = (isset($this->__asset->properties[$p]['required'])) ? $this->__asset->properties[$p]['required'] : true; // is the property required |
| 213 | 213 | $this->__asset_properties[$p]['temp']->limit = (isset($this->__asset->properties[$p]['limit'])) ? $this->__asset->properties[$p]['limit'] : null; // additional options specific to the property |
| 214 | - $this->__asset_properties[$p]['temp']->warning = (isset($this->__asset->properties[$p]['warning'])) ? $this->__asset->properties[$p]['warning'] : null; // additional options specific to the property |
|
| 215 | - $this->__asset_properties[$p]['temp']->max_instances = (isset($this->__asset->properties[$p]['max_instances'])) ? $this->__asset->properties[$p]['max_instances'] : 0; // there can be only one |
|
| 214 | + $this->__asset_properties[$p]['temp']->warning = (isset($this->__asset->properties[$p]['warning'])) ? $this->__asset->properties[$p]['warning'] : null; // additional options specific to the property |
|
| 215 | + $this->__asset_properties[$p]['temp']->max_instances = (isset($this->__asset->properties[$p]['max_instances'])) ? $this->__asset->properties[$p]['max_instances'] : 0; // there can be only one |
|
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | $this->__asset_properties[$each->key] = array('temp' => $each); |
| 232 | 232 | @$this->ownDatastore[$idx]->required = (isset($this->__asset->properties[$each->key]['required'])) ? $this->__asset->properties[$each->key]['required'] : true; |
| 233 | 233 | @$this->ownDatastore[$idx]->limit = (isset($this->__asset->properties[$each->key]['limit'])) ? $this->__asset->properties[$each->key]['limit'] : null; |
| 234 | - @$this->ownDatastore[$idx]->warning = (isset($this->__asset->properties[$each->key]['warning'])) ? $this->__asset->properties[$each->key]['warning'] : null; |
|
| 234 | + @$this->ownDatastore[$idx]->warning = (isset($this->__asset->properties[$each->key]['warning'])) ? $this->__asset->properties[$each->key]['warning'] : null; |
|
| 235 | 235 | @$this->ownDatastore[$idx]->help = (isset($this->__asset->properties[$each->key]['help'])) ? $this->__asset->properties[$each->key]['help'] : null; |
| 236 | 236 | @$this->ownDatastore[$idx]->max_instances = (isset($this->__asset->properties[$each->key]['max_instances'])) ? $this->__asset->properties[$each->key]['max_instances'] : 0; |
| 237 | 237 | @$this->ownDatastore[$idx]->options = (isset($this->__asset->properties[$each->key]['options'])) ? $this->__asset->properties[$each->key]['options'] : null; |
@@ -246,19 +246,19 @@ discard block |
||
| 246 | 246 | { |
| 247 | 247 | |
| 248 | 248 | // we need to create a temporary new bean to store new data |
| 249 | - $this->__asset_properties[$prop]['temp'] = self::getAsset($this->__asset->properties[$prop]['type']); |
|
| 250 | - $this->__asset_properties[$prop]['temp']->name = (isset($this->__asset->properties[$prop]['name'])) ? $this->__asset->properties[$prop]['name'] : null; |
|
| 251 | - $this->__asset_properties[$prop]['temp']->key = $prop; |
|
| 249 | + $this->__asset_properties[$prop]['temp'] = self::getAsset($this->__asset->properties[$prop]['type']); |
|
| 250 | + $this->__asset_properties[$prop]['temp']->name = (isset($this->__asset->properties[$prop]['name'])) ? $this->__asset->properties[$prop]['name'] : null; |
|
| 251 | + $this->__asset_properties[$prop]['temp']->key = $prop; |
|
| 252 | 252 | $this->__asset_properties[$prop]['temp']->private = (isset($this->__asset->properties[$prop]['private'])) ? $this->__asset->properties[$prop]['private'] : false; // accessibility |
| 253 | - $this->__asset_properties[$prop]['temp']->value = (isset($this->__asset->properties[$prop]['value'])) ? $this->__asset->properties[$prop]['value'] : null; // the actual value of the property |
|
| 253 | + $this->__asset_properties[$prop]['temp']->value = (isset($this->__asset->properties[$prop]['value'])) ? $this->__asset->properties[$prop]['value'] : null; // the actual value of the property |
|
| 254 | 254 | $this->__asset_properties[$prop]['temp']->options = (isset($this->__asset->properties[$prop]['options'])) ? $this->__asset->properties[$prop]['options'] : null; // additional options specific to the property |
| 255 | 255 | $this->__asset_properties[$prop]['temp']->callback = (isset($this->__asset->properties[$prop]['callback'])) ? $this->__asset->properties[$prop]['callback'] : null; // additional options specific to the property |
| 256 | 256 | $this->__asset_properties[$prop]['temp']->meta = (isset($this->__asset->properties[$prop]['meta'])) ? $this->__asset->properties[$prop]['meta'] : null; // additional options specific to the property |
| 257 | 257 | $this->__asset_properties[$prop]['temp']->help = (isset($this->__asset->properties[$prop]['help'])) ? $this->__asset->properties[$prop]['help'] : null; // additional options specific to the property |
| 258 | 258 | $this->__asset_properties[$prop]['temp']->required = (isset($this->__asset->properties[$prop]['required'])) ? $this->__asset->properties[$prop]['required'] : true; // is the property required |
| 259 | - $this->__asset_properties[$prop]['temp']->limit = (isset($this->__asset->properties[$prop]['limit'])) ? $this->__asset->properties[$prop]['limit'] : null; // additional options specific to the property |
|
| 260 | - $this->__asset_properties[$prop]['temp']->warning = (isset($this->__asset->properties[$prop]['warning'])) ? $this->__asset->properties[$prop]['warning'] : null; // additional options specific to the property |
|
| 261 | - $this->__asset_properties[$prop]['temp']->max_instances = (isset($this->__asset->properties[$prop]['max_instances'])) ? $this->__asset->properties[$prop]['max_instances'] : null; // there can be only one |
|
| 259 | + $this->__asset_properties[$prop]['temp']->limit = (isset($this->__asset->properties[$prop]['limit'])) ? $this->__asset->properties[$prop]['limit'] : null; // additional options specific to the property |
|
| 260 | + $this->__asset_properties[$prop]['temp']->warning = (isset($this->__asset->properties[$prop]['warning'])) ? $this->__asset->properties[$prop]['warning'] : null; // additional options specific to the property |
|
| 261 | + $this->__asset_properties[$prop]['temp']->max_instances = (isset($this->__asset->properties[$prop]['max_instances'])) ? $this->__asset->properties[$prop]['max_instances'] : null; // there can be only one |
|
| 262 | 262 | |
| 263 | 263 | } |
| 264 | 264 | } |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | public static function getKey($string) |
| 275 | 275 | { |
| 276 | - $new = Helpers::splitByCaps($string); |
|
| 276 | + $new = Helpers::splitByCaps($string); |
|
| 277 | 277 | $explode = explode(' ', $new); |
| 278 | 278 | |
| 279 | 279 | if (isset($explode[0]) && $explode[0] == 'Ams') |
@@ -328,8 +328,8 @@ discard block |
||
| 328 | 328 | break; |
| 329 | 329 | |
| 330 | 330 | case 2: |
| 331 | - $prop = func_get_arg(0); |
|
| 332 | - $val = func_get_arg(1); |
|
| 331 | + $prop = func_get_arg(0); |
|
| 332 | + $val = func_get_arg(1); |
|
| 333 | 333 | if (isset($this->__asset_properties[$prop])) |
| 334 | 334 | { |
| 335 | 335 | // check whether this is new or existing |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | break; |
| 406 | 406 | |
| 407 | 407 | default: |
| 408 | - $val = func_get_arg(0); |
|
| 408 | + $val = func_get_arg(0); |
|
| 409 | 409 | $this->value = $val; |
| 410 | 410 | } |
| 411 | 411 | } |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | |
| 432 | 432 | foreach ($props as $prop) |
| 433 | 433 | { |
| 434 | - if (!in_array($prop->name, array('status_equals', 'properties','help','value_equals'))) |
|
| 434 | + if (!in_array($prop->name, array('status_equals', 'properties', 'help', 'value_equals'))) |
|
| 435 | 435 | { |
| 436 | 436 | $record->{$prop->name} = isset($asset->{$prop->name}) ? $asset->{$prop->name} : NULL; |
| 437 | 437 | } |
@@ -439,15 +439,15 @@ discard block |
||
| 439 | 439 | |
| 440 | 440 | if ($asset->__status_equals) |
| 441 | 441 | { |
| 442 | - $record->status = isset($record->{$asset->__status_equals})? $record->{$asset->__status_equals} : $this->prop($this->__status_equals); |
|
| 442 | + $record->status = isset($record->{$asset->__status_equals}) ? $record->{$asset->__status_equals} : $this->prop($this->__status_equals); |
|
| 443 | 443 | } |
| 444 | 444 | if ($asset->__start_date) |
| 445 | 445 | { |
| 446 | - $record->start_date = isset($record->{$asset->__start_date})? $record->{$asset->__start_date} : $this->prop($this->__start_date); |
|
| 446 | + $record->start_date = isset($record->{$asset->__start_date}) ? $record->{$asset->__start_date} : $this->prop($this->__start_date); |
|
| 447 | 447 | } |
| 448 | 448 | if ($asset->__end_date) |
| 449 | 449 | { |
| 450 | - $record->end_date = isset($record->{$asset->__end_date})? $record->{$asset->__end_date} : $this->prop($this->__end_date); |
|
| 450 | + $record->end_date = isset($record->{$asset->__end_date}) ? $record->{$asset->__end_date} : $this->prop($this->__end_date); |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | $record->options = json_encode($record->options); |
@@ -503,8 +503,8 @@ discard block |
||
| 503 | 503 | public function getMarkup($template = false) |
| 504 | 504 | { |
| 505 | 505 | |
| 506 | - $vars = $this->export(); |
|
| 507 | - $vars['_unique_id'] = uniqid(); |
|
| 506 | + $vars = $this->export(); |
|
| 507 | + $vars['_unique_id'] = uniqid(); |
|
| 508 | 508 | |
| 509 | 509 | // we also want to know what asset this property belongs to |
| 510 | 510 | $output = Helpers::callStatic($this->type, 'render', array($vars, $template)); |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | if ($this->__status_equals) |
| 538 | 538 | { |
| 539 | 539 | |
| 540 | - $data['status'] = isset($data[$this->__status_equals])? $data[$this->__status_equals] : $this->prop($this->__status_equals); |
|
| 540 | + $data['status'] = isset($data[$this->__status_equals]) ? $data[$this->__status_equals] : $this->prop($this->__status_equals); |
|
| 541 | 541 | } |
| 542 | 542 | if ($this->__start_date) |
| 543 | 543 | { |
@@ -598,9 +598,9 @@ discard block |
||
| 598 | 598 | } |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - public function getFieldValues(){ |
|
| 601 | + public function getFieldValues() { |
|
| 602 | 602 | $data = []; |
| 603 | - foreach(array_keys($this->__asset->properties) as $key){ |
|
| 603 | + foreach (array_keys($this->__asset->properties) as $key) { |
|
| 604 | 604 | $data[$key] = $this->prop($key); |
| 605 | 605 | } |
| 606 | 606 | return $data; |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | return $output; |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | - public function propGetValue($prop){ |
|
| 667 | + public function propGetValue($prop) { |
|
| 668 | 668 | dd($prop); |
| 669 | 669 | } |
| 670 | 670 | |
@@ -692,8 +692,8 @@ discard block |
||
| 692 | 692 | { |
| 693 | 693 | if (isset($this->__asset_properties[$prop]['temp'])) |
| 694 | 694 | { |
| 695 | - $xvars = $this->__asset_properties[$prop]['temp']->export(); |
|
| 696 | - $xvars['unique_id'] = $unique_id; |
|
| 695 | + $xvars = $this->__asset_properties[$prop]['temp']->export(); |
|
| 696 | + $xvars['unique_id'] = $unique_id; |
|
| 697 | 697 | |
| 698 | 698 | $output .= Helpers::callStatic($this->__asset_properties[$prop]['temp']->type, 'form', array($xvars, $this->type)); |
| 699 | 699 | } |
@@ -701,8 +701,8 @@ discard block |
||
| 701 | 701 | { |
| 702 | 702 | if (isset($this->__asset_properties[$prop])) |
| 703 | 703 | { |
| 704 | - $xvars = $this->ownDatastore[$this->__asset_properties[$prop]]->export(); |
|
| 705 | - $xvars['unique_id'] = $unique_id; |
|
| 704 | + $xvars = $this->ownDatastore[$this->__asset_properties[$prop]]->export(); |
|
| 705 | + $xvars['unique_id'] = $unique_id; |
|
| 706 | 706 | |
| 707 | 707 | $output .= Helpers::callStatic($this->ownDatastore[$this->__asset_properties[$prop]]->type, 'form', array($xvars, $this->type)); |
| 708 | 708 | } |
@@ -718,8 +718,8 @@ discard block |
||
| 718 | 718 | return $output; |
| 719 | 719 | } |
| 720 | 720 | |
| 721 | - public function hasMetadataForm(){ |
|
| 722 | - if ($this->namespace == 'asset' && !$this->is_child){ |
|
| 721 | + public function hasMetadataForm() { |
|
| 722 | + if ($this->namespace == 'asset' && !$this->is_child) { |
|
| 723 | 723 | return ($this->meta_description !== 'off' || $this->meta_keywords !== 'off'); |
| 724 | 724 | } |
| 725 | 725 | return false; |
@@ -766,8 +766,8 @@ discard block |
||
| 766 | 766 | return $output; |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | - public function hasDeveloperForm(){ |
|
| 770 | - if ($this->namespace == 'asset' && !$this->is_child){ |
|
| 769 | + public function hasDeveloperForm() { |
|
| 770 | + if ($this->namespace == 'asset' && !$this->is_child) { |
|
| 771 | 771 | return ($this->page_js !== 'off' || $this->page_css !== 'off'); |
| 772 | 772 | } |
| 773 | 773 | return false; |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | $output .= Helpers::callStatic(ASSET::METATEXT, 'form', array($data, 'metatext')); |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | - if ($this->page_js !== 'off' ) |
|
| 798 | + if ($this->page_js !== 'off') |
|
| 799 | 799 | { |
| 800 | 800 | $data = array( |
| 801 | 801 | 'name' => 'Custom JS', |
@@ -826,11 +826,11 @@ discard block |
||
| 826 | 826 | $messages = array(); |
| 827 | 827 | foreach ($this->__asset->properties as $key => $property) |
| 828 | 828 | { |
| 829 | - if($property['type'] !== \Phpsa\Datastore\Ams\AutoCallBackAdderAsset::class && (empty($property['required']) || $property['required'] === true) ) |
|
| 829 | + if ($property['type'] !== \Phpsa\Datastore\Ams\AutoCallBackAdderAsset::class && (empty($property['required']) || $property['required'] === true)) |
|
| 830 | 830 | { |
| 831 | 831 | $rules = empty($property['validation_rules']) ? 'required' : $property['validation_rules']; |
| 832 | - if(!empty($property['validation_messages'])){ |
|
| 833 | - if(is_string($property['validation_messages'])){ |
|
| 832 | + if (!empty($property['validation_messages'])) { |
|
| 833 | + if (is_string($property['validation_messages'])) { |
|
| 834 | 834 | $messages[$key . '.required'] = $property['validation_messages']; |
| 835 | 835 | } |
| 836 | 836 | } |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | { |
| 844 | 844 | $validator = Validator::make($request, $config, $messages); |
| 845 | 845 | |
| 846 | - if($validator->fails()){ |
|
| 846 | + if ($validator->fails()) { |
|
| 847 | 847 | throw new ValidationException($validator); |
| 848 | 848 | } |
| 849 | 849 | } |
@@ -967,7 +967,7 @@ discard block |
||
| 967 | 967 | public function getStatusValue() :string |
| 968 | 968 | { |
| 969 | 969 | $options = $this->statusOptions(); |
| 970 | - return (! empty($options) && Helpers::isAssocArray($options) && isset($options[$this->status])) ? $options[$this->status] : $this->status; |
|
| 970 | + return (!empty($options) && Helpers::isAssocArray($options) && isset($options[$this->status])) ? $options[$this->status] : $this->status; |
|
| 971 | 971 | } |
| 972 | 972 | |
| 973 | 973 | /** |
@@ -999,9 +999,9 @@ discard block |
||
| 999 | 999 | */ |
| 1000 | 1000 | public function statusIsActive() :bool |
| 1001 | 1001 | { |
| 1002 | - if($this->__status_equals){ |
|
| 1002 | + if ($this->__status_equals) { |
|
| 1003 | 1003 | |
| 1004 | - if(!isset($this->__asset->properties[$this->__status_equals]['published'])){ |
|
| 1004 | + if (!isset($this->__asset->properties[$this->__status_equals]['published'])) { |
|
| 1005 | 1005 | throw new DatastoreException("Statused assests need a published option in the asset definition"); |
| 1006 | 1006 | } |
| 1007 | 1007 | |
@@ -1052,7 +1052,7 @@ discard block |
||
| 1052 | 1052 | * |
| 1053 | 1053 | * @return string|null |
| 1054 | 1054 | */ |
| 1055 | - public function getTitleField() :?string |
|
| 1055 | + public function getTitleField() : ?string |
|
| 1056 | 1056 | { |
| 1057 | 1057 | return $this->__value_equals; |
| 1058 | 1058 | } |
@@ -13,22 +13,22 @@ |
||
| 13 | 13 | { |
| 14 | 14 | use ValidatesRequests; |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Store a newly created resource in storage. |
|
| 18 | - * |
|
| 19 | - * @param \Illuminate\Http\Request $request |
|
| 20 | - * @return \Illuminate\Http\Response |
|
| 21 | - */ |
|
| 22 | - public function store(Request $request) |
|
| 23 | - { |
|
| 24 | - $request->validate([ |
|
| 16 | + /** |
|
| 17 | + * Store a newly created resource in storage. |
|
| 18 | + * |
|
| 19 | + * @param \Illuminate\Http\Request $request |
|
| 20 | + * @return \Illuminate\Http\Response |
|
| 21 | + */ |
|
| 22 | + public function store(Request $request) |
|
| 23 | + { |
|
| 24 | + $request->validate([ |
|
| 25 | 25 | 'body'=>'required', |
| 26 | 26 | 'datastore_id' => 'required' |
| 27 | - ]); |
|
| 28 | - $input = $request->all(); |
|
| 29 | - $input['user_id'] = auth()->user()->id; |
|
| 30 | - DatastoreComments::create($input); |
|
| 31 | - return back(); |
|
| 32 | - } |
|
| 27 | + ]); |
|
| 28 | + $input = $request->all(); |
|
| 29 | + $input['user_id'] = auth()->user()->id; |
|
| 30 | + DatastoreComments::create($input); |
|
| 31 | + return back(); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function getEditButtonAttribute() |
| 17 | 17 | { |
| 18 | - return '<a href="'.route('admin.ams.content.update', ['asset' => $this->content_path, 'id' => $this->id]).'" data-toggle="tooltip" data-placement="top" title="'.__('buttons.general.crud.edit').'" class="btn btn-primary"><i class="fas fa-edit"></i></a>'; |
|
| 18 | + return '<a href="' . route('admin.ams.content.update', ['asset' => $this->content_path, 'id' => $this->id]) . '" data-toggle="tooltip" data-placement="top" title="' . __('buttons.general.crud.edit') . '" class="btn btn-primary"><i class="fas fa-edit"></i></a>'; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -24,12 +24,12 @@ discard block |
||
| 24 | 24 | public function getDeleteButtonAttribute() |
| 25 | 25 | { |
| 26 | 26 | |
| 27 | - return '<a href="'.route('admin.ams.content.destroy', $this).'" |
|
| 27 | + return '<a href="' . route('admin.ams.content.destroy', $this) . '" |
|
| 28 | 28 | data-method="delete" |
| 29 | - data-trans-button-cancel="'.__('buttons.general.cancel').'" |
|
| 30 | - data-trans-button-confirm="'.__('buttons.general.crud.delete').'" |
|
| 31 | - data-trans-title="'.__('strings.backend.general.are_you_sure').'" |
|
| 32 | - class="btn btn-danger"><i class="fas fa-trash" data-toggle="tooltip" data-placement="top" title="'.__('buttons.general.crud.delete').'"></i></a> '; |
|
| 29 | + data-trans-button-cancel="'.__('buttons.general.cancel') . '" |
|
| 30 | + data-trans-button-confirm="'.__('buttons.general.crud.delete') . '" |
|
| 31 | + data-trans-title="'.__('strings.backend.general.are_you_sure') . '" |
|
| 32 | + class="btn btn-danger"><i class="fas fa-trash" data-toggle="tooltip" data-placement="top" title="'.__('buttons.general.crud.delete') . '"></i></a> '; |
|
| 33 | 33 | |
| 34 | 34 | } |
| 35 | 35 | |
@@ -39,34 +39,34 @@ discard block |
||
| 39 | 39 | public function getActionButtonsAttribute() |
| 40 | 40 | { |
| 41 | 41 | |
| 42 | - if($this->id) |
|
| 42 | + if ($this->id) |
|
| 43 | 43 | { |
| 44 | - return '<div class="btn-group" role="group" aria-label="'.__('labels.backend.access.users.user_actions').'"> |
|
| 45 | - '.$this->edit_button.' |
|
| 46 | - '.$this->delete_button.' |
|
| 44 | + return '<div class="btn-group" role="group" aria-label="' . __('labels.backend.access.users.user_actions') . '"> |
|
| 45 | + '.$this->edit_button . ' |
|
| 46 | + '.$this->delete_button . ' |
|
| 47 | 47 | </div>'; |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function getContentPathAttribute(){ |
|
| 51 | + public function getContentPathAttribute() { |
|
| 52 | 52 | return Helpers::getPath($this->type); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - public function getDatastoreAttribute(){ |
|
| 57 | - if($this->id){ |
|
| 56 | + public function getDatastoreAttribute() { |
|
| 57 | + if ($this->id) { |
|
| 58 | 58 | return DatastoreFactory::getAsset($this->type, $this->id); |
| 59 | 59 | } |
| 60 | - if($this->type){ |
|
| 60 | + if ($this->type) { |
|
| 61 | 61 | return DatastoreFactory::dispence($this->type); |
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public function getRouteAttribute(){ |
|
| 65 | + public function getRouteAttribute() { |
|
| 66 | 66 | return $this->type ? Helpers::callStatic($this->type, 'route', [$this]) : null; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public function routeChild($parentSlug){ |
|
| 69 | + public function routeChild($parentSlug) { |
|
| 70 | 70 | return $this->type ? Helpers::callStatic($this->type, 'route', [$this, $parentSlug]) : null; |
| 71 | 71 | |
| 72 | 72 | } |
@@ -9,36 +9,36 @@ |
||
| 9 | 9 | class DatastoreComments extends Model |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - use SoftDeletes; |
|
| 13 | - |
|
| 14 | - protected $dates = ['deleted_at']; |
|
| 15 | - |
|
| 16 | - /** |
|
| 17 | - * The attributes that are mass assignable. |
|
| 18 | - * |
|
| 19 | - * @var array |
|
| 20 | - */ |
|
| 21 | - protected $fillable = ['user_id', 'datastore_id', 'parent_id', 'body']; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * The belongs to Relationship |
|
| 25 | - * |
|
| 26 | - * @var array |
|
| 27 | - */ |
|
| 28 | - public function user() |
|
| 29 | - { |
|
| 12 | + use SoftDeletes; |
|
| 13 | + |
|
| 14 | + protected $dates = ['deleted_at']; |
|
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * The attributes that are mass assignable. |
|
| 18 | + * |
|
| 19 | + * @var array |
|
| 20 | + */ |
|
| 21 | + protected $fillable = ['user_id', 'datastore_id', 'parent_id', 'body']; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * The belongs to Relationship |
|
| 25 | + * |
|
| 26 | + * @var array |
|
| 27 | + */ |
|
| 28 | + public function user() |
|
| 29 | + { |
|
| 30 | 30 | $user = config('auth.providers.users.model'); |
| 31 | - return $this->belongsTo($user); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * The has Many Relationship |
|
| 36 | - * |
|
| 37 | - * @var array |
|
| 38 | - */ |
|
| 39 | - public function replies() |
|
| 40 | - { |
|
| 41 | - return $this->hasMany(DatastoreComments::class, 'parent_id'); |
|
| 42 | - } |
|
| 31 | + return $this->belongsTo($user); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * The has Many Relationship |
|
| 36 | + * |
|
| 37 | + * @var array |
|
| 38 | + */ |
|
| 39 | + public function replies() |
|
| 40 | + { |
|
| 41 | + return $this->hasMany(DatastoreComments::class, 'parent_id'); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | } |
| 45 | 45 | \ No newline at end of file |
@@ -5,8 +5,8 @@ discard block |
||
| 5 | 5 | use Illuminate\Database\Eloquent\Model; |
| 6 | 6 | use Phpsa\Datastore\Models\Datastore as DatastoreModel; |
| 7 | 7 | /** |
| 8 | - * @property Object $item |
|
| 9 | - */ |
|
| 8 | + * @property Object $item |
|
| 9 | + */ |
|
| 10 | 10 | |
| 11 | 11 | class DatastoreDatastore extends Model |
| 12 | 12 | { |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | public function parent() |
| 26 | - { |
|
| 27 | - return $this->belongsTo(DatastoreModel::class, 'datastore2_id'); |
|
| 26 | + { |
|
| 27 | + return $this->belongsTo(DatastoreModel::class, 'datastore2_id'); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public function page() |
@@ -33,11 +33,11 @@ |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
| 36 | - public function datastore(){ |
|
| 36 | + public function datastore() { |
|
| 37 | 37 | return $this->belongsTo(DatastoreModel::class, 'datastore_id'); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function getItemAttribute(){ |
|
| 40 | + public function getItemAttribute() { |
|
| 41 | 41 | return $this->datastore->datastore; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | 'asset' |
| 20 | 20 | ]; |
| 21 | 21 | |
| 22 | - public function getDatastoreAttribute(){ |
|
| 22 | + public function getDatastoreAttribute() { |
|
| 23 | 23 | return $this->id ? DatastoreCore::getAssetById($this->asset) : null; |
| 24 | 24 | } |
| 25 | 25 | |