目標:エラーの原因を知り、解決したい
問題点:文法的にどこが間違っていて、@forelse文に対してErrorException (E_ERROR)が発生しているのかが分からない
@extends('layouts.default') @section('title', $post->title) @section('content') <h1> <a href="{{ url('/') }}" class="headder-menu">Back</a> {{ $post->title }} </h1> <p>{!! nl2br(e($post->body)) !!}</p> <h2>Comments</h2> <ul> @forelse ($post->comments as $comment) <li> {{ $comment->body }} </li> @empty <li>No comments yet</li> @endforelse </ul> @endsection
上記のコードに対して下記のエラーが発生
<?php $__env->startSection('content'); ?> <h1> <a href="<?php echo e(url('/')); ?>" class="headder-menu">Back</a> <?php echo e($post->title); ?> </h1> <p><?php echo nl2br(e($post->body)); ?></p> <h2>Comments</h2> <ul> <?php $__empty_1 = true; $__currentLoopData = $post->comments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $comment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?> <li> <?php echo e($comment->body); ?> </li> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?> <li>No comments yet</li> <?php endif; ?> </ul> <?php $__env->stopSection(); ?> <?php echo $__env->make('layouts.default', \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?> Arguments "Invalid argument supplied for foreach() (View: /home/vagrant/laravel_lessons/myblog/resources/views/posts/show.blade.php)"
回答1件
あなたの回答
tips
プレビュー