김정명 김정명 - 1 month ago 23
PHP Question

Laravel5.2 error "Trying to get property of non-object"

Suddenly, my page brings two errors. but I don't know about this error. Help!

1/2

ErrorException in e7e9061cce284d56f8d5e5f1771eed43d8f09c38.php line 198:
Trying to get property of non-object

in e7e9061cce284d56f8d5e5f1771eed43d8f09c38.php line 198
at HandleExceptions->handleError('8', 'Trying to get property of non-object','/home/vagrant/Code/Laravel/storage/framework/views/e7e9061cce284d56f8d5e5f1771eed43d8f09c38.php', '198', array('__path' => '/home/vagrant/Code/Laravel/storage/framework/views/e7e9061cce284d56f8d5e5f1771eed43d8f09c38.php', '__data' => array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'boards' => object(board), 'comments' => object(LengthAwarePaginator), 'replies' => object(Collection)), 'obLevel' => '1', '__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'boards' => object(board), 'comments' => object(LengthAwarePaginator), 'replies' => object(Collection), 'comment' => object(comment), 'reply' => object(comment))) in e7e9061cce284d56f8d5e5f1771eed43d8f09c38.php line 198
at include('/home/vagrant/Code/Laravel/storage/framework/views/e7e9061cce284d56f8d5e5f1771eed43d8f09c38.php') in PhpEngine.php line 42
at PhpEngine->evaluatePath('/home/vagrant/Code/Laravel/storage/framework/views/e7e9061cce284d56f8d5e5f1771eed43d8f09c38.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'boards' => object(board), 'comments' => object(LengthAwarePaginator), 'replies' => object(Collection))) in CompilerEngine.php line 59
at CompilerEngine->get('/home/vagrant/Code/Laravel/resources/views/board/show.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'boards' => object(board), 'comments' => object(LengthAwarePaginator), 'replies' => object(Collection))) in View.php line 149
.... blah


2/2

ErrorException in e7e9061cce284d56f8d5e5f1771eed43d8f09c38.php line 198:
Trying to get property of non-object (View: /home/vagrant/Code/Laravel/resources/views/board/show.blade.php)

in e7e9061cce284d56f8d5e5f1771eed43d8f09c38.php line 198
at CompilerEngine->handleViewException(object(ErrorException), '1') in PhpEngine.php line 44
at PhpEngine->evaluatePath('/home/vagrant/Code/Laravel/storage/framework/views/e7e9061cce284d56f8d5e5f1771eed43d8f09c38.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'boards' => object(board), 'comments' => object(LengthAwarePaginator), 'replies' => object(Collection))) in CompilerEngine.php line 59
at CompilerEngine->get('/home/vagrant/Code/Laravel/resources/views/board/show.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'boards' => object(board), 'comments' => object(LengthAwarePaginator), 'replies' => object(Collection))) in View.php line 149
.... blah


this page is loading successfull before . I think some typo exist in my controller, view file , and something but I can't find that.

/storage/framework/views folder for the e7e9061cce284d56f8d5e5f1771eed43d8f09c38.php file
include line 198

var reply_form = reply_form+'<form action="<?php echo e(route('comment.store')); ?>" method="post">';
var reply_form = reply_form+'<input type="hidden" name="page_no" value="<?php echo e($boards->id); ?>">';
var reply_form = reply_form+'<input type="hidden" name="parent_id" value="'+p_article_id+'">';
var reply_form = reply_form+'<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">';
var reply_form = reply_form+'<input type="hidden" name="name" value="<?php echo e(Auth::user()->name); ?>">';
var reply_form = reply_form+'<input type="hidden" name="email" value="<?php echo e(Auth::user()->email); ?>">';// 198 line
var reply_form = reply_form+'<textarea name="comment" placeholder="내용을 입력해주세요"></textarea>';
var reply_form = reply_form+'<input type="submit" value="등록">';
var reply_form = reply_form+'</form>';

Answer

Open that specific view file resources/views/board/show.blade.php, go to line 198. Here check what you are trying to access that really don't exists.

Comments