You are missing an object somewhere in $comment->event->type->name - one of the relations is returning null which is not uncommon. Better to code defensively, and test for existence of the object before using it.
Production not works = same code on dev works :)
Hello!
I have spend 2h searching what wrong, and found zero....
When I call URL http://production.com/comments/index I see that error.
3/3
ErrorException in 1dea0486404fc5ccd0169877e8bb3cc4003b56ab.php line 8:
Trying to get property of non-object (View: /home/aknsvip/domains/production/resources/views/comments/comment.blade.php) (View: /home/aknsvip/domains/production/resources/views/comments/comment.blade.php)
1. in 1dea0486404fc5ccd0169877e8bb3cc4003b56ab.php line 8
2. at CompilerEngine->handleViewException(object(ErrorException), 1) in PhpEngine.php line 44
3. at PhpEngine->evaluatePath('/home/aknsvip/domains/production/storage/framework/views/819ed1c26b86a6fe11ece353533e8ada68efd606.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'comments' => object(LengthAwarePaginator), 'CommentErrorCheck' => null, 'CommentError' => null)) in CompilerEngine.php line 59
Nothing new, very common error. Lets see. In 1dea0486404fc5ccd0169877e8bb3cc4003b56ab.php in line 8 I see this:
<tr>
<td>
<code>
<?php echo e($comment->body); ?>
</code>
<br>
<font size="-1">
<B> <?php echo e($comment->event->type->name); ?> </B> <-----this
<i><?php echo e($comment->user->name); ?> -> (<?php echo e($comment->updated_at); ?>) </i> <------this
</font>
</td>
<td>
<?php if( Auth::user()->role == "Administrator"): ?>
<a href="/events/<?php echo e($comment->event->id); ?>/show" class="btn btn-info btn-sm active" role="button" aria-pressed="true">Info</a> <----this
<a href="/comments/<?php echo e($comment->id); ?>/destroy" class="btn btn-danger btn-sm active" role="button" aria-pressed="true">del</a>
<?php endif; ?>
</td>
</tr>
When I manually remove lines marekt <----this error goes off. And page loaded.
WHY???
I see that errror IS related to calling many to on relation, like in this example :
e($comment->event->type->name);
I have found original file in Comments/index.blade.html this is it;
<font size="-1">
<B> {{ $comment->event->type->name }} </B>
<i>{{ $comment->user->name }} -> ({{ $comment->updated_at}}) </i>
</font>
When I remove this line in my source code, production works.
Tell me why my Production not working with this code, but my development works. I have the same source code on both servers.
Where can I search for help?
This relationships are very vell linked in Comments, Events models. And works in other part of software.
Please or to participate in this conversation.