質問編集履歴
3
ddで出力しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -98,7 +98,19 @@
|
|
98
98
|
|
99
99
|
### 試したこと
|
100
100
|
|
101
|
-
|
101
|
+
viewで出力してみました。
|
102
|
+
|
103
|
+
```
|
104
|
+
|
105
|
+
{{ dd($article->user->name) }} //nameが出力
|
106
|
+
|
107
|
+
{{ dd($article->user) }}//出力なし
|
108
|
+
|
109
|
+
{{ var_dump($article->user->name) }} //string(6) "name"
|
110
|
+
|
111
|
+
{{ var_dump($article->user) }}//object(App\User)#1246 (27) {略}
|
112
|
+
|
113
|
+
```
|
102
114
|
|
103
115
|
|
104
116
|
|
2
article.phpをすべて書きました
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,11 +32,25 @@
|
|
32
32
|
|
33
33
|
```
|
34
34
|
|
35
|
+
<?php
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
namespace App;
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
use Illuminate\Database\Eloquent\Model;
|
44
|
+
|
45
|
+
use Illuminate\Database\Relations\BelongsTo;
|
46
|
+
|
47
|
+
|
48
|
+
|
35
49
|
class Article extends Model
|
36
50
|
|
37
51
|
{
|
38
52
|
|
39
|
-
public function user() :BelongsTo
|
53
|
+
public function user() :BelongsTo
|
40
54
|
|
41
55
|
{
|
42
56
|
|
1
errorメッセージ修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
```
|
20
20
|
|
21
|
-
Return value of App\Article::user() must be an instance of Illuminate\Database\Relations\BelongsTo, instance of
|
21
|
+
Return value of App\Article::user() must be an instance of Illuminate\Database\Relations\BelongsTo, instance of Illuminate\Database\Eloquent\Relations\BelongsTo returned (View: /Users/username/wordbooks/wordbook/bbs/resources/views/articles/card.blade.php)
|
22
22
|
|
23
23
|
```
|
24
24
|
|