Skip to content

Commit 7fd03de

Browse files
authored
Update README.md
1 parent eeb9126 commit 7fd03de

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ composer require santigarcor/laravel-ownable
1717
Then you have to use the `OwnsModels` trait in the models you want to check if they own other models.
1818

1919
```php
20+
<?php
21+
2022
use Ownable\OwnsModels;
2123
use Illuminate\Database\Eloquent\Model;
2224

@@ -31,6 +33,8 @@ You are now ready to use it.
3133
## Usage
3234

3335
```php
36+
<?php
37+
3438
use Ownable\OwnsModels;
3539
use Illuminate\Database\Eloquent\Model;
3640

@@ -59,6 +63,8 @@ if ($user->owns($video, 'the_user_id')){}
5963
If for some reason the ownership check needs a more complex logic, you can implement the `Ownable` interface inside your ownable objects and then you can define your custom logic in the `isOwnedBy` method. When this method is called the object that called the `owns` method is passed as an attribute to the `isOwnedBy` method.
6064

6165
```php
66+
<?php
67+
6268
use Ownable\OwnsModels;
6369
use Illuminate\Database\Eloquent\Model;
6470

@@ -69,10 +75,8 @@ class User extends Model
6975

7076
use Ownable\Contracts\Ownable;
7177

72-
class Video extends Model
78+
class Video extends Model implements Ownable
7379
{
74-
use Ownable;
75-
7680
public function isOwnedBy($owner): bool
7781
{
7882
if ($owner instanceof User) {

0 commit comments

Comments
 (0)