Skip to content

Commit ef78a25

Browse files
committed
update docs
1 parent 17c05c3 commit ef78a25

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Inside a resource’s `ListService`, several properties can be configured to cus
206206
```
207207
- **`$availableFilterColumns`** Specifies which columns of the resource are available for filtering. The default value is `null`, allowing filtering by any field. For security reasons, it’s recommended to explicitly restrict this array to only the columns that should be searchable, e.g.:
208208
```php
209-
protected array $availableFilterColumns = ['is_admin', 'country'];
209+
protected ?array $availableFilterColumns = ['is_admin', 'country'];
210210
```
211211
- **`$availableScopes`** Specifies which scopes are allowed to be applied via the `belongsTo` and `relationId` configurations. The default value is `null`, allowing any scope to be applied. For security reasons, it's recommended to explicitly restrict this array to only the scopes that should be allowed, e.g.:
212212
```php
@@ -744,6 +744,18 @@ protected function createQuery()
744744
}
745745
```
746746

747+
With the following code in the `createQuery()` method, you can ensure that the listed items always belong to the company associated with the current user.
748+
749+
```php
750+
protected function createQuery()
751+
{
752+
$user = Auth::user();
753+
throw_if(is_null($user), AuthenticationException::class);
754+
755+
return $this->listModel::query()->where('company_id', $user->company_id);
756+
}
757+
```
758+
747759
### Actions
748760

749761
To define particular behaviors for each type of action, we use action classes. Actions must extend the abstract `CrudAction` class.

0 commit comments

Comments
 (0)