質問編集履歴

1

環境とログを追記

2021/01/01 03:29

投稿

Tikka123456
Tikka123456

スコア34

test CHANGED
File without changes
test CHANGED
@@ -23,6 +23,86 @@
23
23
  8 | Tikka
24
24
 
25
25
  (1 row)
26
+
27
+ 追記
28
+
29
+ 環境
30
+
31
+ Laravel:Laravel Framework 6.18.20
32
+
33
+ OS: Windows10
34
+
35
+
36
+
37
+ Laravelのログ
38
+
39
+ ```ここに言語を入力
40
+
41
+ local.ERROR: Trying to get property 'articles' of non-object {"userId":8,"exception":"[object] (ErrorException(code: 0): Trying to get property 'articles' of non-object at /var/www/app/Http/Controllers/UserController.php:20)
42
+
43
+ ```
44
+
45
+
46
+
47
+ articlesを定義しているコード
48
+
49
+ ```ここに言語を入力
50
+
51
+ <?php
52
+
53
+
54
+
55
+ namespace App\Http\Controllers;
56
+
57
+
58
+
59
+ use App\Article;
60
+
61
+ use App\Comment;
62
+
63
+ use App\Tag;
64
+
65
+ use Illuminate\Http\Request;
66
+
67
+ use App\Http\Requests\ArticleRequest;
68
+
69
+
70
+
71
+
72
+
73
+ class ArticleController extends Controller
74
+
75
+ {
76
+
77
+ public function __construct()
78
+
79
+ {
80
+
81
+ $this->authorizeResource(Article::class, 'article');
82
+
83
+ }
84
+
85
+
86
+
87
+ public function index()
88
+
89
+ {
90
+
91
+ $articles = Article::with(['user', 'likes', 'tags'])
92
+
93
+ ->orderByDesc('created_at')
94
+
95
+ ->paginate(5);
96
+
97
+
98
+
99
+
100
+
101
+ return view('articles.index', ['articles' => $articles]);
102
+
103
+ }
104
+
105
+ ```
26
106
 
27
107
 
28
108