L
L
lynnikvadim2015-09-10 04:45:50
Laravel
lynnikvadim, 2015-09-10 04:45:50

Form error with Laravel?

There is such code in view:

{!! Form::open(['route'=>'categorystore','method' => 'POST', 'files' => true]) !!}
                  <div class="form-group">
                  <label>Имя категории:</label>
                    <div class="input-group">
                      <div class="input-group-addon">
                        <i class="fa fa-user"></i>
                      </div>
                      {!! Form::text('name', null, ['class'=>'form-control pull-right' ]) !!}
                      
                    </div>                
                </div>
                <div class="form-group">
                  <label>Родитель:</label>
                    <div class="input-group">
                      <div class="input-group-addon">
                       <i class="fa fa-key"></i>
                      </div>
                    <select class="form-control pull-right typers"  name="fname">
                    <option value="0">Нет родителя</option>
     @foreach ($Category as $Category)

     <option value="{{$Category->id}}">{{$Category->name}}</option>
   
@endforeach
    
   </select>
                     
                    </div>       
                    <small></small>            
                </div>               
                

                <div class="form-group">
                  <label>Картинка:</label>
                    <div class="input-group">
                      <div class="input-group-addon">
                        <i class="fa fa-envelope-o"></i>
                      </div>
                      {!! Form::file('img', null, ['class'=>'form-control pull-right' ]) !!}
                      
                    </div>                
                </div>
                    
                
               
                
                {!! Form::submit('Создать',['class'=>'btn btn-block btn-success']) !!}
                {!! Form::close() !!}
 
                </div><!-- /.box-body -->
          
  </div>
           
              <div class="box box-solid">
                <div class="box-header with-border">
                  <h3 class="box-title">Категории</h3>
                </div><!-- /.box-header -->
                <div class="box-body">
                  <div class="box-group" id="accordion">
                    <!-- we are adding the .panel class so bootstrap.js collapse plugin detects it -->
                    <div class="panel box box-primary">
                      <div class="box-header with-border">
                        <h4 class="box-title">
                          <a class="collapsed" aria-expanded="false" data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
                            
                            @foreach ($Category as $Category)
                             {{$Category->name}}

                             @endforeach
                          </a>
                        </h4>
                      </div>
                      <div style="height: 0px;" aria-expanded="false" id="collapseOne" class="panel-collapse collapse">
                        <div class="box-body">
                          Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
                        </div>
                      </div>
                    </div>
                  
                  
                  </div>
                </div><!-- /.box-body -->
              </div><!-- /.box -->

when opening the page it says:
Trying to get property of non-object (View: /var/www/html/proj1/resources/views/admin/Category.blade.php)
What's the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mrfanta, 2015-09-10
@mrfanta

Most likely you $Categorydo not have an object, that is, the category was not found in the database or whatever you have there.
The controller that generates the page in the studio.

V
Vyacheslav Plisko, 2015-09-10
@AmdY

foreach ($Category as $Category)
wtf? why are you using the same name for the collection and the item in it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question