Skip to content

Commit ec0ef64

Browse files
committed
Add access control instructions to README
Document how to implement and use the `CanAccessAnalyticsDashboard` interface in the User model for controlling dashboard access. This clarifies the setup process for managing user permissions.
1 parent d44663e commit ec0ef64

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,30 @@ php artisan vendor:publish --tag="request-analytics-views"
7070
```php
7171
$requestAnalytics = new MeShaon\RequestAnalytics();
7272
echo $requestAnalytics->echoPhrase('Hello, MeShaon!');
73+
```
74+
## Access Control
75+
76+
### Web Access
77+
To control access to the dashboard, implement the `CanAccessAnalyticsDashboard` interface in your User model:
78+
Then you can use the `canAccessAnalyticsDashboard` method in your your `User` model:
79+
```php
80+
<?php
81+
82+
namespace App\Models;
83+
84+
// use Illuminate\Contracts\Auth\MustVerifyEmail;
85+
use App\Enums\Role;
86+
use MeShaon\RequestAnalytics\Contracts\CanAccessAnalyticsDashboard;
87+
88+
class User extends Authenticatable implements CanAccessAnalyticsDashboard
89+
{
90+
91+
public function canAccessAnalyticsDashboard(): bool
92+
{
93+
return $this->role === Role::ADMIN;
94+
}
95+
}
96+
7397
```
7498

7599
## Testing

0 commit comments

Comments
 (0)