Skip to content

Commit

Permalink
Merge branch 'develop' into fix/psr-12
Browse files Browse the repository at this point in the history
  • Loading branch information
bennothommo authored Dec 30, 2024
2 parents 27207c2 + 20a73ff commit 1d5e517
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 32 deletions.
22 changes: 11 additions & 11 deletions modules/backend/assets/ui/js/build/vendor.js

Large diffs are not rendered by default.

41 changes: 30 additions & 11 deletions modules/backend/formwidgets/TagList.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Backend\Classes\FormWidgetBase;
use Illuminate\Database\Eloquent\Relations\Relation as RelationBase;
use Winter\Storm\Database\Relations\BelongsToMany;
use Winter\Storm\Database\Relations\MorphToMany;

/**
* Tag List Form Widget
Expand Down Expand Up @@ -125,29 +127,46 @@ public function getSaveValue($value)
*/
protected function hydrateRelationSaveValue($names): ?array
{
if (!$names) {
return $names;
}

if (!is_array($names)) {
$names = [$names];
}

$names = array_filter($names);

$relation = $this->getRelationObject();
$relationModel = $this->getRelationModel();
$existingTags = $relationModel
->whereIn($this->nameFrom, $names)
->lists($this->nameFrom, $relationModel->getKeyName())
;

$keyName = $relationModel->getKeyName();
$pivot = in_array(get_class($relation), [BelongsToMany::class, MorphToMany::class]);

if ($pivot) {
$existingTags = $relationModel->whereIn($this->nameFrom, $names)->lists($this->nameFrom, $keyName);
} else {
$existingTags = $relation->lists($this->nameFrom, $keyName);
}

$newTags = $this->customTags ? array_diff($names, $existingTags) : [];
$deletedTags = $this->customTags ? array_diff($existingTags, $names) : [];

foreach ($newTags as $newTag) {
$newModel = new $relationModel();
$newModel->{$this->nameFrom} = $newTag;
$newModel->save();
if ($pivot) {
$newModel = new $relationModel();
$newModel->{$this->nameFrom} = $newTag;
$newModel->save();
} else {
$newModel = $relation->create([$this->nameFrom => $newTag]);
}
$existingTags[$newModel->getKey()] = $newTag;
}

if (!$pivot && $deletedTags) {
$deletedKeys = array_keys($deletedTags);
$relation->whereIn($keyName, $deletedKeys)->delete();
foreach ($deletedTags as $id) {
unset($existingTags[$id]);
}
}

return array_keys($existingTags);
}

Expand Down
1 change: 1 addition & 0 deletions modules/backend/formwidgets/taglist/partials/_taglist.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
value="<?= $field->value ?>">
<?php endif ?>
<?php else: ?>
<input type="hidden" name="<?= $field->getName() ?>[]">
<select
id="<?= $field->getId() ?>"
name="<?= $field->getName() ?>[]"
Expand Down
7 changes: 1 addition & 6 deletions modules/backend/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Event::fire('backend.beforeRoute');

/*
* Other pages
* Route everything to `Backend\Classes\BackendController`, which itself acts as a router for the Backend.
*/
Route::group([
'middleware' => ['web'],
Expand All @@ -29,11 +29,6 @@
Route::any('{slug?}', 'Backend\Classes\BackendController@run')->where('slug', '(.*)?');
});

/*
* Entry point
*/
Route::any(Config::get('cms.backendUri', 'backend'), 'Backend\Classes\BackendController@run')->middleware('web');

/**
* @event backend.route
* Fires after backend routes have been added
Expand Down
2 changes: 1 addition & 1 deletion modules/system/assets/js/build/system.debug.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/system/assets/js/build/system.js

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified modules/system/assets/ui/font/fa-brands-400.ttf
Binary file not shown.
Binary file modified modules/system/assets/ui/font/fa-brands-400.woff2
Binary file not shown.
Binary file modified modules/system/assets/ui/font/fa-regular-400.ttf
Binary file not shown.
Binary file modified modules/system/assets/ui/font/fa-regular-400.woff2
Binary file not shown.
Binary file modified modules/system/assets/ui/font/fa-solid-900.ttf
Binary file not shown.
Binary file modified modules/system/assets/ui/font/fa-solid-900.woff2
Binary file not shown.
Binary file modified modules/system/assets/ui/font/fa-v4compatibility.ttf
Binary file not shown.
Binary file modified modules/system/assets/ui/font/fa-v4compatibility.woff2
Binary file not shown.
2 changes: 1 addition & 1 deletion modules/system/assets/ui/icons.css

Large diffs are not rendered by default.

0 comments on commit 1d5e517

Please sign in to comment.