Skip to content

Commit

Permalink
Add note in readme about this issue laravel/framework#51825
Browse files Browse the repository at this point in the history
  • Loading branch information
Admin committed Feb 20, 2025
1 parent 0533115 commit 17540fd
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,55 @@ III.5. [Delete resource](#iii5-delete-resource)

## II. Start using it

**NOTE**

The lib contains a backward compatible fix for this issue https://github.com/laravel/framework/issues/51825

This will not cover the cases when the relation is instantiated in the model without calling the functions from the HasRelationship trait (or to be more precise, from HasCleverRelationships trait)!
Those cases will still have this issue.

To cover also those cases, for example for HasManyThrough use in model anonymous class:

```php
return new class (
$query,
$farParent,
$throughParent,
$firstKey,
$secondKey,
$localKey,
$secondLocalKey,
$this // this is crucial
) extends HasManyThrough {
public function __construct(
Builder $query,
Model $farParent,
Model $throughParent,
string $firstKey,
string $secondKey,
string $localKey,
string $secondLocalKey,
BaseModel $resourceModel
) {
$this->setConstraintsStaticFlag($resourceModel);

return parent::__construct(
$query,
$farParent,
$throughParent,
$firstKey,
$secondKey,
$localKey,
$secondLocalKey
);
}
};
```

Register

\MacropaySolutions\LaravelCrudWizard\Providers\CrudProvider

\MacropaySolutions\LaravelCrudWizard\Http\Middleware\UnescapedJsonMiddleware::class in lumen or laravel.

Create a constant in your code
Expand Down

0 comments on commit 17540fd

Please sign in to comment.