Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
858df49
POC for https://github.com/laravel/framework/discussions/31778 + http…
Nov 1, 2025
8899de9
POC for https://github.com/laravel/framework/discussions/31778 + http…
Nov 1, 2025
c51442f
POC for https://github.com/laravel/framework/discussions/31778 improv…
Nov 2, 2025
55f0ff6
POC for https://github.com/laravel/framework/discussions/31778 bullet…
Nov 2, 2025
24b2342
POC for https://github.com/laravel/framework/discussions/31778 bullet…
Nov 2, 2025
d769af5
POC for https://github.com/laravel/framework/discussions/31778 bullet…
Nov 2, 2025
650073a
POC for https://github.com/laravel/framework/discussions/31778 bullet…
Nov 2, 2025
8e1719b
POC for https://github.com/laravel/framework/discussions/31778 avoid …
Nov 2, 2025
b46eef1
POC for https://github.com/laravel/framework/discussions/31778 reduce…
Nov 3, 2025
6936364
POC for https://github.com/laravel/framework/discussions/31778 cr
Nov 3, 2025
1b3b508
POC for https://github.com/laravel/framework/discussions/31778 reduce…
Nov 3, 2025
d55e116
POC for https://github.com/laravel/framework/discussions/31778 handle…
Nov 3, 2025
f706b2c
Add trait for testing
Nov 3, 2025
432bd6b
POC for https://github.com/laravel/framework/discussions/31778 cr
Nov 3, 2025
85d8f3f
POC for https://github.com/laravel/framework/discussions/31778 cr
Nov 4, 2025
e47d26b
POC for https://github.com/laravel/framework/discussions/31778 cr
Nov 4, 2025
2f9f369
POC for https://github.com/laravel/framework/discussions/31778 cr
Nov 4, 2025
6b5cdf0
POC for https://github.com/laravel/framework/discussions/31778 cr
Nov 4, 2025
e8ce6e6
POC for https://github.com/laravel/framework/discussions/31778 cover …
Nov 4, 2025
703390e
POC for https://github.com/laravel/framework/discussions/31778 cover …
Nov 4, 2025
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
21 changes: 21 additions & 0 deletions src/Eloquent/CustomRelations/HasCleverRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,27 @@ public function __construct(
$relationName
);
}

/**
* @inheritdoc
*/
protected function migratePivotAttributes(Model $model): array
{
$values = [];

foreach (\array_keys($model->getAttributes(true)) as $key) {
// To get the pivots attributes we will just take any of the attributes which
// begin with "pivot_" and add those to this arrays, as well as unsetting
// them from the parent's models since they exist in a different table.
if (str_starts_with($key, 'pivot_')) {
$values[substr($key, 6)] = $model->getAttributeFromArray($key);

unset($model->$key);
}
}

return $values;
}
};
}

Expand Down
16 changes: 12 additions & 4 deletions src/Http/Controllers/ResourceControllerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,21 @@ public function update(string $identifier, Request $request): JsonResponse
$all = $request->all();

try {
$model = $this->resourceService->get($identifier, appendIndex: false);
$model->fill(GeneralHelper::filterDataByKeys($all, \array_diff(
$toFill = GeneralHelper::filterDataByKeys($all, \array_diff(
$this->resourceService->getModelColumns(),
$this->resourceService->getIgnoreExternalUpdateFor()
)));
));

if ($toFill === []) {
return GeneralHelper::app(JsonResponse::class, [
'data' => $this->resourceService->get($identifier)->toArray(),
'status' => 200
]);
}

$model = $this->resourceService->get($identifier, appendIndex: false)->fill($toFill);
/** $request can contain also files so, overwrite this function to handle them */
$request->forceReplace($model->getDirty());
$request->forceReplace($model->getDirty(\array_keys($toFill)));

return GeneralHelper::app(JsonResponse::class, [
'data' => $this->resourceService->update($identifier, $this->validateUpdateRequest($request))
Expand Down
Loading