Skip to content

Commit

Permalink
Improve README
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Jul 13, 2024
1 parent 9612a42 commit 542fcec
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Country extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function comments()
public function comments(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeepFromRelationsWithConstraints([$this, 'posts'], [new Post(), 'comments']);
}
Expand Down Expand Up @@ -156,7 +156,7 @@ class Country extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function comments()
public function comments(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Comment::class, [User::class, Post::class]);
}
Expand All @@ -174,7 +174,7 @@ class Country extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function comments()
public function comments(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(
Comment::class,
Expand All @@ -201,7 +201,7 @@ class Country extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function comments()
public function comments(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Comment::class, [User::class, Post::class], [null, 'custom_user_id']);
}
Expand All @@ -225,7 +225,7 @@ class User extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function permissions()
public function permissions(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Permission::class, ['role_user', Role::class]);
}
Expand All @@ -239,7 +239,7 @@ class User extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function permissions()
public function permissions(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(
Permission::class,
Expand Down Expand Up @@ -272,7 +272,7 @@ class User extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function permissions()
public function permissions(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Permission::class, ['role_user', Role::class, 'permission_role']);
}
Expand All @@ -294,7 +294,7 @@ class User extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function postComments()
public function postComments(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(
Comment::class,
Expand All @@ -321,7 +321,7 @@ class User extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function postTags()
public function postTags(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(
Tag::class,
Expand Down Expand Up @@ -351,7 +351,7 @@ class Tag extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function postComments()
public function postComments(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(
Comment::class,
Expand All @@ -375,7 +375,7 @@ class Tag extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function postAuthors()
public function postAuthors(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(
User::class,
Expand All @@ -396,7 +396,7 @@ class Country extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function latestComment()
public function latestComment(): \Staudenmeir\EloquentHasManyDeep\HasOneDeep
{
return $this->hasOneDeep(Comment::class, [User::class, Post::class])
->latest('comments.created_at');
Expand All @@ -419,7 +419,7 @@ class User extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function projects()
public function projects(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(
Project::class,
Expand All @@ -436,7 +436,7 @@ class User extends Model
Use `withIntermediate()` to retrieve attributes from intermediate tables:

```php
public function comments()
public function comments(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Comment::class, [User::class, Post::class])
->withIntermediate(Post::class);
Expand All @@ -453,7 +453,7 @@ columns.
You can specify the selected columns as the second argument:

```php
public function comments()
public function comments(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Comment::class, [User::class, Post::class])
->withIntermediate(Post::class, ['id', 'title']);
Expand All @@ -463,7 +463,7 @@ public function comments()
As the third argument, you can specify a custom accessor:

```php
public function comments()
public function comments(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Comment::class, [User::class, Post::class])
->withIntermediate(Post::class, ['id', 'title'], 'accessor');
Expand All @@ -477,7 +477,7 @@ foreach ($country->comments as $comment) {
If you retrieve data from multiple tables, you can use nested accessors:

```php
public function comments()
public function comments(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Comment::class, [User::class, Post::class])
->withIntermediate(Post::class)
Expand All @@ -493,7 +493,7 @@ foreach ($country->comments as $comment) {
Use `withPivot()` for the pivot tables of `BelongsToMany` and `MorphToMany`/`MorphedByMany` relationships:

```php
public function permissions()
public function permissions(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Permission::class, ['role_user', Role::class])
->withPivot('role_user', ['expires_at']);
Expand All @@ -507,7 +507,7 @@ foreach ($user->permissions as $permission) {
You can specify a custom pivot model as the third argument and a custom accessor as the fourth:

```php
public function permissions()
public function permissions(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Permission::class, ['role_user', Role::class])
->withPivot('role_user', ['expires_at'], RoleUser::class, 'pivot');
Expand All @@ -527,7 +527,7 @@ class Country extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function comments()
public function comments(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Comment::class, [User::class, Post::class]);
}
Expand All @@ -545,7 +545,7 @@ class Post extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function commentReplies()
public function commentReplies(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Comment::class, [Comment::class . ' as alias'], [null, 'parent_id']);
}
Expand All @@ -568,7 +568,7 @@ class User extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function permissions()
public function permissions(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Permission::class, [RoleUser::class . ' as alias', Role::class]);
}
Expand All @@ -587,7 +587,7 @@ class Post extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function commentReplies()
public function commentReplies(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeepFromRelations(
$this->comments(),
Expand Down Expand Up @@ -621,7 +621,7 @@ class Country extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function comments()
public function comments(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Comment::class, [User::class, Post::class])
->withTrashed('users.deleted_at');
Expand Down Expand Up @@ -669,7 +669,7 @@ class Country extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function comments()
public function comments(): \Staudenmeir\EloquentHasManyDeep\HasManyDeep
{
return $this->hasManyDeep(Comment::class, [User::class, Post::class]);
}
Expand All @@ -679,7 +679,7 @@ class Comment extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

public function country()
public function country(): \Staudenmeir\EloquentHasManyDeep\HasOneDeep
{
return $this->hasOneDeepFromReverse(
(new Country())->comments()
Expand Down

0 comments on commit 542fcec

Please sign in to comment.