Skip to content

Commit 794e5a7

Browse files
Adds BelongTo and HasMany as the function return types (#109)
1 parent 0eea3b2 commit 794e5a7

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

tests/Feature/Fixtures/Comment.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
namespace Tests\Feature\Fixtures;
44

55
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
67

78
class Comment extends Model
89
{
910
protected $table = 'comments';
1011

1112
protected $guarded = [];
1213

13-
public function podcast()
14+
public function podcast(): BelongsTo
1415
{
1516
return $this->belongsTo(Podcast::class, 'podcast_id');
1617
}

tests/Feature/Fixtures/Movie.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
namespace Tests\Feature\Fixtures;
44

55
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
67

78
class Movie extends Model
89
{
910
protected $table = 'movies';
1011

1112
protected $guarded = [];
1213

13-
public function user()
14+
public function user(): BelongsTo
1415
{
1516
return $this->belongsTo(User::class, 'user_id');
1617
}

tests/Feature/Fixtures/Podcast.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Database\Eloquent\Model;
66
use Illuminate\Database\Eloquent\SoftDeletes;
7+
use Illuminate\Database\Eloquent\Relations\HasMany;
78

89
class Podcast extends Model
910
{
@@ -13,7 +14,7 @@ class Podcast extends Model
1314

1415
protected $guarded = [];
1516

16-
public function comments()
17+
public function comments(): HasMany
1718
{
1819
return $this->hasMany(Comment::class);
1920
}

0 commit comments

Comments
 (0)