Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

unknown_'s avatar

syntax error, unexpected end of file

I keep getting the message, which is in the title, for the 145ba5a124cf3e653f6b59e6acf30206719d86de.php file, which is made automatically, so I did not type or paste anything in it. I cannot understand what the issue is. This is the code:

<?php $__env->startSection('content'); ?>

           <div class="row">
               <div class="col-lg-12 margin-tb">
                   <div class="pull-left">
                       <h2>All Blogs</h2>
                   </div>
               </div>
           </div>
          
           <?php if($message = Session::get('success')): ?>
               <div class="alert alert-success">
                   <p><?php echo e($message); ?></p>
               </div>
           <?php endif; ?>
          
           <table class="table table-bordered">
               <tr>
                   <th>No</th>
                   <th>Title</th>
                   <th>Description</th>
                   <th width="250px">Action</th>
               </tr>
               <?php $__currentLoopData = $blog; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $blog): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
               <?php $__currentLoopData = $blogs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $blog): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
       <tr>
           <td><?php echo e($i); ?></td>
           <td><?php echo e($blog->title); ?></td>
           <td><?php echo e($blog->description); ?></td>
           <td>
               <a class="btn btn-info" href="<?php echo e(route('blogs.show',$blog->id)); ?>">Show</a>
               <a class="btn btn-primary" href="<?php echo e(route('blogs.edit',$blog->id)); ?>">Edit</a>
               <form action="<?php echo e(route('blogs.destroy', $blog->id)); ?>" method="POST">
                   <?php echo csrf_field(); ?>
                   <?php echo method_field('DELETE'); ?>
                   <button type="submit" class="btn btn-danger">Delete</button>
               </form>
           </td>
       </tr>
       <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
       </table>
           </table>
           <div class="pull-right">
                   <a class="btn btn-primary" href="/"> Back</a>
               </div>
       <?php $__env->stopSection(); ?>
       <?php echo $__env->make('blogs.layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\Users\Benuzter\Desktop\firstProject\resources\views/blogs/index.blade.php ENDPATH**/ ?>

And this is index.blade.php:

@extends('blogs.layout')
 
@section('content')
           
    <div class="row">
        <div class="col-lg-12 margin-tb">
            <div class="pull-left">
                <h2>All Blogs</h2>
            </div>
        </div>
    </div>
   
    @if ($message = Session::get('success'))
        <div class="alert alert-success">
            <p>{{ $message }}</p>
        </div>
    @endif
   
    <table class="table table-bordered">
        <tr>
            <th>No</th>
            <th>Title</th>
            <th>Description</th>
            <th width="250px">Action</th>
        </tr>
        @foreach ($blog as $blog)
        @foreach ($blogs as $i => $blog)
<tr>
    <td>{{ $i}}</td>
    <td>{{ $blog->title }}</td>
    <td>{{ $blog->description }}</td>
    <td>
        <a class="btn btn-info" href="{{ route('blogs.show',$blog->id) }}">Show</a>
        <a class="btn btn-primary" href="{{ route('blogs.edit',$blog->id) }}">Edit</a>
        <form action="{{ route('blogs.destroy', $blog->id) }}" method="POST">
            @csrf
            @method('DELETE')
            <button type="submit" class="btn btn-danger">Delete</button>
        </form>
    </td>
</tr>
@endforeach
</table>
    </table>
    <div class="pull-right">
            <a class="btn btn-primary" href="/"> Back</a>
        </div>
@endsection
0 likes
5 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

You start 2 foreach

        @foreach ($blog as $blog)
        @foreach ($blogs as $i => $blog)

but only end one of them

@endforeach

Please or to participate in this conversation.