Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/get slug infinite requests #540

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Http/Controllers/Admin/ModuleController.php
Expand Up @@ -528,7 +528,7 @@ public function bulkPublish()
*/
public function destroy($id, $submoduleId = null)
{
$item = $this->repository->getById($id);
$item = $this->repository->getById($submoduleId ?? $id);
if ($this->repository->delete($submoduleId ?? $id)) {
$this->fireEvent();
activity()->performedOn($item)->log('deleted');
Expand Down
10 changes: 5 additions & 5 deletions src/Repositories/Behaviors/HandleBrowsers.php
Expand Up @@ -46,9 +46,9 @@ public function getFormFieldsHandleBrowsers($object, $fields)
}
}
}

return $fields;
}
}

/**
* @param \A17\Twill\Models\Model $object
Expand All @@ -70,7 +70,7 @@ public function updateBrowser($object, $fields, $relationship, $positionAttribut

$object->$relationship()->sync($relatedElementsWithPosition);
}

/**
* @param \A17\Twill\Models\Model $object
* @param array $fields
Expand All @@ -81,7 +81,7 @@ public function updateBrowser($object, $fields, $relationship, $positionAttribut
public function updateOrderedBelongsTomany($object, $fields, $relationship, $positionAttribute = 'position') {
$this->updateBrowser($object, $fields, $relationship, $positionAttribute);
}

/**
* @param mixed $object
* @param array $fields
Expand Down Expand Up @@ -127,7 +127,7 @@ public function getFormFieldsForRelatedBrowser($object, $relation)
'id' => $relatedElement->id,
'name' => $relatedElement->titleInBrowser ?? $relatedElement->title,
'endpointType' => $relatedElement->getMorphClass(),
] + (($relatedElement->adminEditUrl ?? null) ? [] : [
] + (empty($relatedElement->adminEditUrl) ? [] : [
'edit' => $relatedElement->adminEditUrl,
]) + (classHasTrait($relatedElement, HasMedias::class) ? [
'thumbnail' => $relatedElement->defaultCmsImage(['w' => 100, 'h' => 100]),
Expand Down
3 changes: 2 additions & 1 deletion src/Repositories/Behaviors/HandleSlugs.php
Expand Up @@ -77,7 +77,8 @@ public function forSlug($slug, $with = [], $withCount = [], $scopes = [])
$item->redirect = true;
}

if (!$item && config('translatable.use_property_fallback', false)) {
if (!$item && config('translatable.use_property_fallback', false)
&& config('translatable.fallback_locale') != config('app.locale')) {
$item = (clone $query)->orWhere(function ($query) {
return $query->withActiveTranslations(config('translatable.fallback_locale'));
})->forFallbackLocaleSlug($slug)->first();
Expand Down