質問編集履歴

3

編集質問

2018/02/19 05:51

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
 
13
- ログインした後のURLが下記のなっています
13
+ ログインした後のURLが下記のようになっています
14
14
 
15
15
 
16
16
 

2

修正

2018/02/19 05:51

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- Laravel5 いきなりTrying to get property of non-object エラーです
1
+ Laravel5 Trying to get property of non-object エラーです
test CHANGED
@@ -216,6 +216,8 @@
216
216
 
217
217
  ビューに表示するためのindexファイル:
218
218
 
219
+ index.Controller.php
220
+
219
221
  ```
220
222
 
221
223
 

1

質問修正

2018/02/19 05:32

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,8 +1,24 @@
1
- 半年前から問題なかったのですが今日いきなりに下記のエラーができました。
2
-
3
- 原因は非オブジェクトのプパティを取得しようとするときにダメでたみたすがどうのよう解決できすか?
1
+ グインするときに下記のエラーが出て、しかしJOBSテーブルにjob_idのデータあればエラーはなりせん。
2
+
3
+
4
+
4
-
5
+ 原因はjob_idのデータがないからですが初期状態はjob_idデータがないのが正しいので、初期状態でもエラーが出ないようにするにはどうすればいいですか?
6
+
5
-
7
+ 教えてくださませ!!
8
+
9
+
10
+
11
+
12
+
13
+ ログインした後のURLが下記のなっています
14
+
15
+
16
+
17
+ ```
18
+
19
+ example.com/home/before_login_actions
20
+
21
+ ```
6
22
 
7
23
 
8
24
 
@@ -22,7 +38,7 @@
22
38
 
23
39
 
24
40
 
25
- Controllers/UserBaseController.phpは下記です。
41
+ エラーで表示されているファイルControllers/UserBaseController.phpは下記です。
26
42
 
27
43
 
28
44
 
@@ -195,3 +211,233 @@
195
211
  $job_ids = explode(',', $job->job_id);
196
212
 
197
213
  ```
214
+
215
+
216
+
217
+ ビューに表示するためのindexファイル:
218
+
219
+ ```
220
+
221
+
222
+
223
+ <?php
224
+
225
+
226
+
227
+ namespace App\Http\Controllers;
228
+
229
+
230
+
231
+ use Illuminate\Http\Request;
232
+
233
+ use App\User;
234
+
235
+ use App\Job;
236
+
237
+ use App\Apply_users;
238
+
239
+ use App\Location;
240
+
241
+ use App\Job_categories;
242
+
243
+ use App\Industry;
244
+
245
+ use App\Language;
246
+
247
+ use App\Language_level;
248
+
249
+ use App\Education;
250
+
251
+ use App\Http\Controllers\UserBaseController;
252
+
253
+ use Illuminate\Support\Facades\Config;
254
+
255
+ use Mail;
256
+
257
+
258
+
259
+ class HomeController extends UserBaseController
260
+
261
+ {
262
+
263
+ public function index(Request $request)
264
+
265
+ {
266
+
267
+ $search = $request->all();
268
+
269
+ $user_id = $this->user_id;
270
+
271
+ $apply_users_and_job_data = Apply_users::get_apply_user_list($search, $user_id);
272
+
273
+
274
+
275
+ $apply_users = $apply_users_and_job_data['apply_users'];
276
+
277
+ $data['job_list'] = $apply_users_and_job_data['job_list'];
278
+
279
+ $job_ids = array();
280
+
281
+ if (!empty($data['job_list'])) {
282
+
283
+ foreach ($data['job_list'] as $job) {
284
+
285
+ $job_ids[] = $job->job_id;
286
+
287
+ }
288
+
289
+ }
290
+
291
+ //重複削除
292
+
293
+ $job_ids = (!empty($job_ids)) ? array_unique($job_ids) : array();
294
+
295
+ $apply_user_emails = array();
296
+
297
+ foreach ($apply_users as $key => $apply_user) {
298
+
299
+ if (in_array($apply_user->job_id, $job_ids)) {
300
+
301
+ $apply_user_emails[] = $apply_user->email;
302
+
303
+ $now = intval(date('Ymd'));
304
+
305
+ $birth = intval($apply_user->birth_on);
306
+
307
+ $apply_users[$key]->age = floor(($now - $birth) / 10000);
308
+
309
+ } else {
310
+
311
+ unset($apply_users[$key]);
312
+
313
+ }
314
+
315
+ }
316
+
317
+ $duplicated_emails = getDuplicatedArray($apply_user_emails);
318
+
319
+ $data['apply_users'] = $apply_users;
320
+
321
+ $data['user_status_list'] = config('user_status.user_status');
322
+
323
+ $data['duplicated_emails'] = $duplicated_emails;
324
+
325
+ $data['search'] = $search;
326
+
327
+ $data['locations'] = Location::all();
328
+
329
+ $data['industries'] = Industry::all();
330
+
331
+ $data['educations'] = Education::all();
332
+
333
+ $data['categories'] = Job_categories::all();
334
+
335
+ $data['language_levels'] = Language_level::all();
336
+
337
+ $data['languages'] = Language::all();
338
+
339
+ $data['current_user'] = User::find($this->user_id);
340
+
341
+ $data['apply_user_count'] = Apply_users::get_apply_user_count($this->user_id);
342
+
343
+
344
+
345
+ return view('home', $data);
346
+
347
+ }
348
+
349
+
350
+
351
+ public function show($id, Request $request)
352
+
353
+ {
354
+
355
+ $eager_list = [
356
+
357
+ 'Job',
358
+
359
+ 'Apply_job_offers',
360
+
361
+ 省略..
362
+
363
+ ];
364
+
365
+
366
+
367
+ $apply_users = Apply_users::with($eager_list)->findOrfail($id);
368
+
369
+
370
+
371
+ // status名取得
372
+
373
+ $user_status = config('user_status.user_status');
374
+
375
+
376
+
377
+ $apply_users->status_name = $user_status[$apply_users->status];
378
+
379
+ // 重複チェック
380
+
381
+ $same_apply_users = Apply_users::where(['email' => $apply_users->email, 'user_id' => $this->user_id])->get();
382
+
383
+ $data['duplicated_flg'] = (count($same_apply_users) > 1) ? TRUE : FALSE;
384
+
385
+ // update reading-flg
386
+
387
+ $data['current_user'] = User::find($this->user_id);
388
+
389
+ if ($apply_users->reading_flg == 0) {
390
+
391
+ Apply_users::where(['id' => $apply_users->id])->update(['reading_flg' => 1]);
392
+
393
+ // update not read count
394
+
395
+ $update_user_param['not_read_count'] = $data['current_user']->not_read_count - 1;
396
+
397
+ User::where(['id' => $this->user_id])->update($update_user_param);
398
+
399
+ $data['current_user'] = User::find($this->user_id);
400
+
401
+ }
402
+
403
+
404
+
405
+ $data['apply_users'] = $apply_users;
406
+
407
+ $data['apply_users']['phone_format'] = phone_format($apply_users->phone);
408
+
409
+ $data['apply_users']['age_calculation'] = age_calculation($apply_users->birth_on);
410
+
411
+ $data['user_status'] = $user_status;
412
+
413
+ $data['apply_user_count'] = Apply_users::get_apply_user_count($this->user_id);
414
+
415
+
416
+
417
+ return view('apply_users.details', $data);
418
+
419
+ }
420
+
421
+
422
+
423
+ public function before_login_actions(Request $request)
424
+
425
+ {
426
+
427
+ $this->update_all_counts($request);
428
+
429
+ return redirect('/home');
430
+
431
+ }
432
+
433
+ 省略...
434
+
435
+
436
+
437
+ }
438
+
439
+
440
+
441
+
442
+
443
+ ```