This ussualy happens when you are trying to access a function on an inexisting object. For example, if you have in your code:
{{ $student->math_class->created_at->format('M d, Y') }}
... but $student has'nt a math_class relationship, then created_at is null (not a Carbon date object) and you can't use the function format on that inexisting object.
In blade, I use the next ternary operator to prevent crash:
{{ $student->math_class ? $student->math_class->created_at->format('M d, Y') : '--' }}
Thank you Rafa, I tried to edit my codes but sadly it's giving me the same error.
Check your database. Probably the date field is null, or it has an invalid value like '0000-00-00'. If you can share your portion of code, it helps a lot.
<table class="table table-bordered table-condensed">
<tr>
<th class="col-xs-2"><?php echo e(trans('evaluations.attributes.notice_number')); ?></th>
<td class="col-xs-2"><?php echo e($evaluation->notice->number); ?></td>
<th class="col-xs-2"><?php echo e(trans('evaluations.attributes.notice_type')); ?></th>
<td class="col-xs-2"><?php echo e($evaluation->type ? $evaluation->type->name : blank_icon(nil)); ?></td>
<th class="col-xs-2"><?php echo e(trans('evaluations.attributes.organization')); ?></th>
<td class="col-xs-2"><?php echo e($evaluation->notice->organization->name); ?></td>
</tr>
<tr>
<th class="col-xs-2"><?php echo e(trans('evaluations.attributes.submission')); ?></th>
<td class="col-xs-2"><?php echo e($evaluation->submission->number); ?></td>
<th class="col-xs-2"><?php echo e(trans('evaluations.attributes.submitted_at')); ?></th>
<td class="col-xs-2"><?php echo e($evaluation->submission ? $evaluation->submission->submitted_at->format('DD/MM/YYYY') : 'HH:mm:ss'); ?></td>
<th class="col-xs-2"><?php echo e(trans('evaluations.attributes.type')); ?></th>
<td class="col-xs-2"><?php echo e($evaluation->type ? $evaluation->type->name : blank_icon(nil)); ?></td>
</tr>
</table>
</div>
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community