I'm doing a php system and I miss this code problem

-1
  

syntax error, unexpected ')', expecting '('
  in 95fa8dfb635d690d28edcc5a99f8d587929a8d61.php

The route that leaves by clicking on it is

  

C: \ CursoLaravel \ sisSales \ storage \ framework \ views (line 33)

and this is the line that redirects me to the link (this is line 33):

<div class="form-group">
                <label>Categoria</label>
                <select name="idcategoria" class="form-control">
                    <?php $__currentLoopData = $categoria; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as cat): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($cat->idcategoria); ?>"><?php echo e($cat->nombre); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
    
asked by Angel_08 31.10.2017 в 07:12
source

2 answers

3

Indenting your code a bit (and converting everything to PHP instead of interpolating HTML) you have

echo '<div class="form-group">';
echo '<label>Categoria</label>';
echo '<select name="idcategoria" class="form-control">';

$__currentLoopData = $categoria; 
$__env->addLoop($__currentLoopData); 

foreach($__currentLoopData as cat): 
   $__env->incrementLoopIndices(); 
   $loop = $__env->getLastLoop(); 

   echo '<option value="'. e($cat->idcategoria) .'">'.e($cat->nombre).'</option>';

endforeach; 

$__env->popLoop(); 
$loop = $__env->getLastLoop();

echo '</select>';
echo '</div>';

There it looks a little clearer than

 foreach($__currentLoopData as cat): 

is misspelled. It should be

 foreach($__currentLoopData as $cat): 

I had no idea that Laravel had that global function of convenience e to escape html entities. Another magic of Laravel. I hate the magic of Laravel.

    
answered by 31.10.2017 в 11:30
1

Improve the format of your code to easily locate those errors:

<div class="form-group">
    <label>Categoria</label>
    <select name="idcategoria" class="form-control">

        <?php 
            $__env->addLoop( $categoria ); 

            foreach ( $categoria as $cat ) {
                $__env->incrementLoopIndices(); 
                $loop = $__env->getLastLoop(); 
        ?>
        <option value="<?php echo e( $cat->idcategoria ); ?>">
            <?php echo e( $cat->nombre ); ?>
        </option>

        <?php 
            } //endforeach

            $__env->popLoop(); 
            $loop = $__env->getLastLoop(); 

        ?>
    </select>
</div>

You had an error in the foreach declaration: foreach($__currentLoopData as $cat) , to $ cat you missed the $ sign that goes to the start of all PHP variables.

Otherwise, change the foreach to the traditional format that is most readable to me.

    
answered by 31.10.2017 в 08:36