質問編集履歴

2

追記:ヘルパ関数

2018/06/28 06:26

投稿

mogu_7
mogu_7

スコア7

test CHANGED
File without changes
test CHANGED
@@ -157,3 +157,141 @@
157
157
 
158
158
 
159
159
  エラー内容を調べて「配列やオブジェクトをキーに使用できない…」という文を見つけたのですが、どこでそのような指定をしてしまっているのわかりません。どこを修正すればよいのでしょうか?
160
+
161
+
162
+
163
+ ### 追記
164
+
165
+ 「ヘルパ関数を~」とのことでしたので追記。ヘルパー関数の使い方がよくわからず、とりあえずコントローラ側にdd($items)を追記し実行したところ下記のように表示されました。
166
+
167
+ ```PHP
168
+
169
+ LengthAwarePaginator {#945 ▼
170
+
171
+ #total: 2
172
+
173
+ #lastPage: 1
174
+
175
+ #items: Collection {#937 ▼
176
+
177
+ #items: array:2 [▼
178
+
179
+ 0 => List_d {#934 ▼
180
+
181
+ #table: "list_d"
182
+
183
+ #primaryKey: array:2 [▼
184
+
185
+ 0 => "pers_id"
186
+
187
+ 1 => "refe_ymd"
188
+
189
+ ]
190
+
191
+ +timestamps: false
192
+
193
+ #connection: "sqlite"
194
+
195
+ #keyType: "int"
196
+
197
+ +incrementing: true
198
+
199
+ #with: []
200
+
201
+ #withCount: []
202
+
203
+ #perPage: 15
204
+
205
+ +exists: true
206
+
207
+ +wasRecentlyCreated: false
208
+
209
+ #attributes: array:4 [▼
210
+
211
+ "pers_id" => "1"
212
+
213
+ "refe_ymd" => "20180614"
214
+
215
+ "check1" => "1710"
216
+
217
+ "check2" => "1448"
218
+
219
+ ]
220
+
221
+ #original: array:4 [▼
222
+
223
+ "pers_id" => "1"
224
+
225
+ "refe_ymd" => "20180614"
226
+
227
+ "check1" => "1710"
228
+
229
+ "check2" => "1448"
230
+
231
+ ]
232
+
233
+ #changes: []
234
+
235
+ #casts: []
236
+
237
+ #dates: []
238
+
239
+ #dateFormat: null
240
+
241
+ #appends: []
242
+
243
+ #dispatchesEvents: []
244
+
245
+ #observables: []
246
+
247
+ #relations: []
248
+
249
+ #touches: []
250
+
251
+ #hidden: []
252
+
253
+ #visible: []
254
+
255
+ #fillable: []
256
+
257
+ #guarded: array:1 [▼
258
+
259
+ 0 => "*"
260
+
261
+ ]
262
+
263
+ }
264
+
265
+ 1 => List_d {#935 ▶}
266
+
267
+ ]
268
+
269
+ }
270
+
271
+ #perPage: 5
272
+
273
+ #currentPage: 1
274
+
275
+ #path: "http://localhost/List/index"
276
+
277
+ #query: []
278
+
279
+ #fragment: null
280
+
281
+ #pageName: "page"
282
+
283
+ }
284
+
285
+ ```
286
+
287
+ 「0 =>」と書いてあったので、ビュー側の表示方法が間違いなのか?と思い
288
+
289
+ <td>{{ $item->refe_ymd }}</td> を、 <td>{{ $item[0]->refe_ymd }}</td> と修正しました。
290
+
291
+ するとエラー内容が変わりました。
292
+
293
+ ```log
294
+
295
+ Trying to get property 'pers_id' of non-object
296
+
297
+ ```

1

2018/06/28 06:26

投稿

mogu_7
mogu_7

スコア7

test CHANGED
File without changes
test CHANGED
File without changes