Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
rupadana authored Feb 8, 2024
2 parents ce3b929 + b2a0517 commit d865fad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ php artisan make:filament-api-service BlogResource

From version 3.0, routes automatically registered. it will grouped as '/api/`admin`'. `admin` is panelId.


So, You don't need to register the routes manually.

The routes will be :
Expand All @@ -48,12 +47,21 @@ On CreateHandler, you need to be create your custom request validation.

## Token Resource

By default, Token resource only show on `super_admin` role. you can modify it by publishing config and change `api-service.can_access.role`
By default, Token resource only show on `super_admin` role. you can modify give permission to other permission too.

Token Resource is protected by TokenPolicy. You can disable it by publishing the config and change this line.

```php
'models' => [
'token' => [
'enable_policy' => false // default: true
]
],
```

## Filtering & Allowed Field

We used `"spatie/laravel-query-builder": "^5.3"` to handle query selecting, sorting and filtering. Check out [the spatie/laravel-query-builder documentation](https://spatie.be/docs/laravel-query-builder/v5/introduction) for more information.

You can specified `allowedFilters` and `allowedFields` in your model. For example:

```php
Expand Down Expand Up @@ -166,19 +174,10 @@ To Generate Token, you just need create it from admin panel. It will be Token Re

![Image](https://res.cloudinary.com/rupadana/image/upload/v1704958748/Screenshot_2024-01-11_at_15.37.55_ncpg8n.png)

By default, Token Resource is protected by TokenPolicy. You can disable it by publishing the config and change this line.

```php
'models' => [
'token' => [
'enable_policy' => false // default: true
]
],
```

## TODO

- [ ] Test Plugin for Tenancy purpose
- [ ] Each user can manage their own token only

## Changelog

Expand Down
2 changes: 1 addition & 1 deletion config/api-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
'models' => [
'token' => [
'enable_policy' => true,
'enable_policy' => true
],
],
];
5 changes: 3 additions & 2 deletions src/Policies/TokenPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function viewAny(User $user): bool
if (! $this->isPolicyEnabled()) {
return true;
}

return $user->can('view_any_token');
}

Expand All @@ -47,7 +47,7 @@ public function create(User $user): bool
if (! $this->isPolicyEnabled()) {
return true;
}

return $user->can('create_token');
}

Expand All @@ -68,6 +68,7 @@ public function update(User $user, Token $token): bool
*/
public function delete(User $user, Token $token): bool
{

if (! $this->isPolicyEnabled()) {
return true;
}
Expand Down

0 comments on commit d865fad

Please sign in to comment.