Skip to content

Commit

Permalink
Improve README
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Jul 15, 2024
1 parent 3ff5a42 commit a267a2f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class User extends Model
'options' => 'json',
];

public function roles()
public function roles(): \Staudenmeir\EloquentJsonRelations\Relations\BelongsToJson
{
return $this->belongsToJson(Role::class, 'options->role_ids');
}
Expand All @@ -154,7 +154,7 @@ class Role extends Model
{
use \Staudenmeir\EloquentJsonRelations\HasJsonRelationships;

public function users()
public function users(): \Staudenmeir\EloquentJsonRelations\Relations\HasManyJson
{
return $this->hasManyJson(User::class, 'options->role_ids');
}
Expand Down Expand Up @@ -187,7 +187,7 @@ class User extends Model
'options' => 'json',
];

public function roles()
public function roles(): \Staudenmeir\EloquentJsonRelations\Relations\BelongsToJson
{
return $this->belongsToJson(Role::class, 'options->roles[]->role_id');
}
Expand All @@ -197,7 +197,7 @@ class Role extends Model
{
use \Staudenmeir\EloquentJsonRelations\HasJsonRelationships;

public function users()
public function users(): \Staudenmeir\EloquentJsonRelations\Relations\HasManyJson
{
return $this->hasManyJson(User::class, 'options->roles[]->role_id');
}
Expand Down Expand Up @@ -233,7 +233,7 @@ Pass an array of keys that starts with JSON key:
```php
class Employee extends Model
{
public function tasks()
public function tasks(): \Staudenmeir\EloquentJsonRelations\Relations\BelongsToJson
{
return $this->belongsToJson(
Task::class,
Expand All @@ -245,7 +245,7 @@ class Employee extends Model

class Task extends Model
{
public function employees()
public function employees(): \Staudenmeir\EloquentJsonRelations\Relations\HasManyJson
{
return $this->hasManyJson(
Employee::class,
Expand Down Expand Up @@ -385,15 +385,15 @@ class User extends Model
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
use \Staudenmeir\EloquentJsonRelations\HasJsonRelationships;

public function permissions()
public function permissions(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeepFromRelations(
$this->roles(),
(new Role)->permissions()
);
}

public function roles()
public function roles(): \Staudenmeir\EloquentJsonRelations\Relations\BelongsToJson
{
return $this->belongsToJson(Role::class, 'options->role_ids');
}
Expand Down

0 comments on commit a267a2f

Please sign in to comment.