File tree 4 files changed +8
-7
lines changed
4 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 23
23
"orchestra/testbench" : " ^8.0|^9.0|^10.0" ,
24
24
"laravel/legacy-factories" : " ^1.0.4" ,
25
25
"friendsofphp/php-cs-fixer" : " ^3.13" ,
26
- "larastan/larastan" : " ^2.0"
26
+ "larastan/larastan" : " ^2.0|^3.0 "
27
27
},
28
28
"autoload" : {
29
29
"psr-4" : {
Original file line number Diff line number Diff line change 4
4
5
5
use Cesargb \Database \Support \CascadeDelete ;
6
6
use Illuminate \Database \Eloquent \Model ;
7
+ use Illuminate \Database \Eloquent \Relations \MorphOne ;
7
8
8
9
/**
9
- * @property \Tests\Models\Image $image
10
+ * @property ? \Tests\Models\Image $image
10
11
*/
11
12
class User extends Model
12
13
{
@@ -16,7 +17,7 @@ class User extends Model
16
17
17
18
protected $ fillable = ['name ' ];
18
19
19
- public function image ()
20
+ public function image (): MorphOne
20
21
{
21
22
return $ this ->morphOne (Image::class, 'imageable ' );
22
23
}
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ public function test_clean_residual_morph_relations_from_model_morph_many()
75
75
76
76
$ this ->assertEquals (2 , $ numRowsDeleted );
77
77
$ this ->assertEquals (2 , Option::count ());
78
- $ this ->assertNotNull (2 , Photo::where ('id ' , 1 )->first ()->options ()->count ());
78
+ $ this ->assertEquals (2 , Photo::where ('id ' , 1 )->first ()->options ()->count ());
79
79
}
80
80
81
81
public function test_clean_residual_morph_relations_from_model_morph_to_many ()
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ public function test_delete_morph_relations_from_event_model__morph_one()
22
22
});
23
23
24
24
$ this ->assertEquals (2 , Image::count ());
25
- $ this ->assertNotNull (User::first ()->image );
25
+ $ this ->assertNotNull (User::with ( ' image ' )-> first ()->image );
26
26
27
27
User::first ()->delete ();
28
28
@@ -38,12 +38,12 @@ public function test_delete_morph_relations_from_record_model__morph_one()
38
38
});
39
39
40
40
$ this ->assertEquals (2 , Image::count ());
41
- $ this ->assertNotNull (User::first ()->image );
41
+ $ this ->assertNotNull (User::with ( ' image ' )-> first ()->image );
42
42
43
43
(new Morph ())->delete (User::first ());
44
44
45
45
$ this ->assertEquals (1 , Image::count ());
46
- $ this ->assertNull (User::first ()->image );
46
+ $ this ->assertNull (User::with ( ' image ' )-> first ()->image );
47
47
}
48
48
49
49
public function test_delete_morph_relations_from_record_model__morph_many ()
You can’t perform that action at this time.
0 commit comments