Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tehwave committed Feb 6, 2020
1 parent ad72c27 commit a8f31d4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,30 @@ $user = \App\User::find(1);
$user->achievements()->get();
```

### Checking if entity has Achievement

On models with the `Achiever` trait, you may pass an `Achievement` instance to `hasAchievement` method to check if the specified achievement exist on the model.

```php
$achievement = new \App\Achievements\UsersFirstPost();

$user = \App\User::find(1);

$user->hasAchievement($achievement);
// false

$user->achieve($achievement);

$user->hasAchievement($achievement);
// true
```

Should you not want to pass an instance, you may also pass the class name.

```php
$user->hasAchievement(\App\Achievements\UsersFirstPost::class);
```

## Tests

```bash
Expand Down

0 comments on commit a8f31d4

Please sign in to comment.