Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix BlockRepository setting relation of an object and improve amount … #2672

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix use of make and position is in the wrong place
  • Loading branch information
Tofandel committed Oct 15, 2024
commit a9a1d52dfec50ff1073ff226b5dfa9da6728a587
4 changes: 2 additions & 2 deletions src/Repositories/Behaviors/HandleRevisions.php
Original file line number Diff line number Diff line change
@@ -158,10 +158,10 @@ public function hydrateRelatedBrowsers(TwillModelContract $object, array $fields
foreach ($relatedBrowsers as $browser) {
$browserField = $fields['browsers'][$browser['browserName']] ?? [];

$position = 1;
foreach ($browserField as $values) {
$position = 1;

$relatedBrowserItems->push(RelatedItem::make([
$relatedBrowserItems->push(new RelatedItem([
'subject_id' => $object->getKey(),
'subject_type' => $object->getMorphClass(),
'related_id' => $values['id'],
2 changes: 1 addition & 1 deletion src/Repositories/BlockRepository.php
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ public function hydrate(TwillModelContract $model, array $fields): TwillModelCon
{
$relatedItems = collect($fields['browsers'])
->flatMap(fn($items, $browserName) => collect($items)
->map(fn($item, $position) => RelatedItem::make([
->map(fn($item, $position) => new RelatedItem([
'subject_id' => $model->getKey(),
'subject_type' => $model->getMorphClass(),
'related_id' => $item['id'],
Loading