@@ -104,9 +104,6 @@ discard block |
||
| 104 | 104 | * Handle relation search action. |
| 105 | 105 | * Currently used for SelectField with type `select2` and `ajax = true`. |
| 106 | 106 | * |
| 107 | - * @param string $field |
|
| 108 | - * @param string $page |
|
| 109 | - * @param string $term |
|
| 110 | 107 | * @return \Illuminate\Http\JsonResponse |
| 111 | 108 | */ |
| 112 | 109 | public function searchRelation(Request $request) |
@@ -712,6 +709,9 @@ discard block |
||
| 712 | 709 | } |
| 713 | 710 | } |
| 714 | 711 | |
| 712 | + /** |
|
| 713 | + * @param string $title |
|
| 714 | + */ |
|
| 715 | 715 | protected function addTab($title, array $fields) |
| 716 | 716 | { |
| 717 | 717 | foreach ($fields as $field) { |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | /** |
| 808 | 808 | * Check if user has permission for the action. |
| 809 | 809 | * |
| 810 | - * @param $action |
|
| 810 | + * @param string $action |
|
| 811 | 811 | * @return bool |
| 812 | 812 | */ |
| 813 | 813 | protected function can($action): bool |
@@ -273,6 +273,9 @@ discard block |
||
| 273 | 273 | return sprintf('%s%s%s/force-delete', $this->baseUrl(), self::BASE_URL_DELIMITER, $id); |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | + /** |
|
| 277 | + * @param string $identifier |
|
| 278 | + */ |
|
| 276 | 279 | public function toolbarUrl($identifier) |
| 277 | 280 | { |
| 278 | 281 | return sprintf('%s%stoolbar/%s', $this->baseUrl(), self::BASE_URL_DELIMITER, $identifier); |
@@ -325,6 +328,9 @@ discard block |
||
| 325 | 328 | return rtrim($chunks[0], '/'); |
| 326 | 329 | } |
| 327 | 330 | |
| 331 | + /** |
|
| 332 | + * @param integer $ident |
|
| 333 | + */ |
|
| 328 | 334 | public function tableIdentifier($ident = null) |
| 329 | 335 | { |
| 330 | 336 | if (is_null($ident)) { |
@@ -369,6 +375,9 @@ discard block |
||
| 369 | 375 | $this->preferences()->saveCurrentLocale($this->tableIdentifier(), $locale); |
| 370 | 376 | } |
| 371 | 377 | |
| 378 | + /** |
|
| 379 | + * @return \Illuminate\Http\Request |
|
| 380 | + */ |
|
| 372 | 381 | public function getTool($ident) |
| 373 | 382 | { |
| 374 | 383 | if (array_key_exists($ident, $this->toolbar)) { |
@@ -40,6 +40,9 @@ |
||
| 40 | 40 | return $field; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | + /** |
|
| 44 | + * @param string $model |
|
| 45 | + */ |
|
| 43 | 46 | public function setModel($model) |
| 44 | 47 | { |
| 45 | 48 | $this->model = $model; |
@@ -52,6 +52,9 @@ |
||
| 52 | 52 | return $this; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | + /** |
|
| 56 | + * @return string |
|
| 57 | + */ |
|
| 55 | 58 | public function getPath() |
| 56 | 59 | { |
| 57 | 60 | return $this->path; |
@@ -5,18 +5,18 @@ discard block |
||
| 5 | 5 | use Illuminate\Http\Request; |
| 6 | 6 | use Yaro\Jarboe\Table\CRUD; |
| 7 | 7 | |
| 8 | -class MassDeleteTool extends AbstractTool |
|
| 9 | -{
|
|
| 8 | +class MassDeleteTool extends AbstractTool |
|
| 9 | +{ |
|
| 10 | 10 | /** |
| 11 | 11 | * Set CRUD object. |
| 12 | 12 | * |
| 13 | 13 | * @param CRUD $crud |
| 14 | 14 | */ |
| 15 | - public function setCrud(CRUD $crud) |
|
| 16 | - {
|
|
| 15 | + public function setCrud(CRUD $crud) |
|
| 16 | + { |
|
| 17 | 17 | parent::setCrud($crud); |
| 18 | 18 | |
| 19 | - if ($this->check()) {
|
|
| 19 | + if ($this->check()) { |
|
| 20 | 20 | $this->crud()->enableBatchCheckboxes(true); |
| 21 | 21 | } |
| 22 | 22 | } |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * Position where should tool be placed. |
| 26 | 26 | */ |
| 27 | - public function position() |
|
| 28 | - {
|
|
| 27 | + public function position() |
|
| 28 | + { |
|
| 29 | 29 | return self::POSITION_BODY_TOP; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | /** |
| 41 | 41 | * Tool's view. |
| 42 | 42 | */ |
| 43 | - public function render() |
|
| 44 | - {
|
|
| 43 | + public function render() |
|
| 44 | + { |
|
| 45 | 45 | return view('jarboe::crud.toolbar.mass_delete', [
|
| 46 | 46 | 'tool' => $this, |
| 47 | 47 | 'crud' => $this->crud(), |
@@ -55,24 +55,24 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return \Illuminate\Http\JsonResponse |
| 57 | 57 | */ |
| 58 | - public function handle(Request $request) |
|
| 59 | - {
|
|
| 58 | + public function handle(Request $request) |
|
| 59 | + { |
|
| 60 | 60 | $errors = []; |
| 61 | 61 | $hidden = []; |
| 62 | 62 | $removed = []; |
| 63 | - foreach ($request->get('ids') as $id) {
|
|
| 64 | - try {
|
|
| 65 | - if (!$this->crud()->repo()->delete($id)) {
|
|
| 63 | + foreach ($request->get('ids') as $id) { |
|
| 64 | + try { |
|
| 65 | + if (!$this->crud()->repo()->delete($id)) { |
|
| 66 | 66 | throw new \Exception(__('jarboe::toolbar.mass_delete.delete_event_failed'));
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - try {
|
|
| 69 | + try { |
|
| 70 | 70 | $this->crud()->repo()->find($id); |
| 71 | 71 | $hidden[] = $id; |
| 72 | - } catch (\Exception $e) {
|
|
| 72 | + } catch (\Exception $e) { |
|
| 73 | 73 | $removed[] = $id; |
| 74 | 74 | } |
| 75 | - } catch (\Exception $e) {
|
|
| 75 | + } catch (\Exception $e) { |
|
| 76 | 76 | $errors[$id] = $e->getMessage(); |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -150,10 +150,12 @@ |
||
| 150 | 150 | $model->{$this->getRelationMethod($index)}()->saveMany($relatedList); |
| 151 | 151 | break; |
| 152 | 152 | case MorphToMany::class: |
| 153 | - if ($relation['group']) { // is morphedByMany |
|
| 153 | + if ($relation['group']) { |
|
| 154 | +// is morphedByMany |
|
| 154 | 155 | $ids = $this->filterValuesForMorphToManyRelation($ids, crc32($relation['group'])); |
| 155 | 156 | $model->{$this->getRelationMethod($index)}()->sync($ids); |
| 156 | - } else { // is morphToMany |
|
| 157 | + } else { |
|
| 158 | +// is morphToMany |
|
| 157 | 159 | $model->{$this->getRelationMethod($index)}()->update([ |
| 158 | 160 | $model->{$this->getRelationMethod($index)}()->getMorphType() => null, |
| 159 | 161 | $model->{$this->getRelationMethod($index)}()->getForeignPivotKeyName() => null, |
@@ -254,6 +254,9 @@ |
||
| 254 | 254 | return $this; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | + /** |
|
| 258 | + * @return integer |
|
| 259 | + */ |
|
| 257 | 260 | abstract public function getModel(); |
| 258 | 261 | abstract public function isMultiple(); |
| 259 | 262 | } |
@@ -9,9 +9,13 @@ |
||
| 9 | 9 | private $styles = []; |
| 10 | 10 | private $scripts = []; |
| 11 | 11 | |
| 12 | - private function __construct() {} |
|
| 12 | + private function __construct() |
|
| 13 | + { |
|
| 14 | +} |
|
| 13 | 15 | |
| 14 | - private function __clone() {} |
|
| 16 | + private function __clone() |
|
| 17 | + { |
|
| 18 | +} |
|
| 15 | 19 | |
| 16 | 20 | private static function getInstance() |
| 17 | 21 | { |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | use Yaro\Jarboe\Console\Commands\Make\Tool as MakeTool; |
| 10 | 10 | use Yaro\Jarboe\Helpers\Locale; |
| 11 | 11 | |
| 12 | -class ServiceProvider extends IlluminateServiceProvider |
|
| 12 | +class ServiceProvider extends IlluminateServiceProvider |
|
| 13 | 13 | { |
| 14 | 14 | |
| 15 | 15 | /** |
@@ -25,18 +25,18 @@ |
||
| 25 | 25 | </thead> |
| 26 | 26 | <?php |
| 27 | 27 | |
| 28 | -if (!empty($_POST)) |
|
| 29 | -{ |
|
| 30 | - foreach ( $_POST as $key => $value ) |
|
| 31 | - { |
|
| 32 | - if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) ) |
|
| 33 | - continue; |
|
| 28 | +if (!empty($_POST)) { |
|
| 29 | + foreach ( $_POST as $key => $value ) { |
|
| 30 | + if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) ) { |
|
| 31 | + continue; |
|
| 32 | + } |
|
| 34 | 33 | |
| 35 | - if ( get_magic_quotes_gpc() ) |
|
| 36 | - $value = htmlspecialchars( stripslashes((string)$value) ); |
|
| 37 | - else |
|
| 38 | - $value = htmlspecialchars( (string)$value ); |
|
| 39 | -?> |
|
| 34 | + if ( get_magic_quotes_gpc() ) { |
|
| 35 | + $value = htmlspecialchars( stripslashes((string)$value) ); |
|
| 36 | + } else { |
|
| 37 | + $value = htmlspecialchars( (string)$value ); |
|
| 38 | + } |
|
| 39 | + ?> |
|
| 40 | 40 | <tr> |
| 41 | 41 | <th style="vertical-align: top"><?php echo htmlspecialchars( (string)$key ); ?></th> |
| 42 | 42 | <td><pre class="samples"><?php echo $value; ?></pre></td> |