samedi 22 juin 2019

Trying to get property 'id' of non-object (View: E:\xampp\htdocs\mini_blog\resources\views\admin\posts\edit.blade.php)

Trying to get property 'id' of non-object how to fix the bug, please explain to me, someone

edit.blade.php

@extends('layouts.app')

@section('content')

<div class="card">
              <div class="card-header text-center">Edit Post : </div>

              <div class="card-body">
                  @if(count($errors)>0)

              <ul class="list-group alert">
                  @foreach($errors->all() as $error)
                  <li class="list-group-item text-danger">
                      
                  </li>

                  @endforeach
              </ul>

                  @endif

                <form action="" method="post" enctype="multipart/form-data">
                  
                    <div class="form-group">
                        <label for="title">Post Title</label>
                        <input type="text" name="title" placeholder="Enter" class="form-control" value=" ">
                    </div>
                    <div class="form-group">
                        <label for="image">Featured Image</label>
                        <input type="file" name="image" class="form-control">
                    </div>

                    <div class="form-group">
                        <label for="category">Select a Category</label>
                        <select name="category_id" id="category" class="form-control">
                          @foreach($categories as $cat)
                          <option value=""

                          @if($posts->cat->id== $cat->id) 
                            selected 
                          @endif

                            ></option>

                          @endforeach
                        </select>
                    </div>

                       <div class="form-group">
                        <label for="tag">Select Tags</label>
                  @foreach($tag as $tags)

                  <div class="checkbox">
                    <label><input type="checkbox" name="tags[]" value=""

                    @foreach($posts->tags as $t)

                  @if($tags->id==$t->id)
                  checked 

                  @endif
                    @endforeach
                      ></label>
                  </div>

                  @endforeach
                    </div>

                    <div class="form-group">
                        <label for="content">Description</label>
                        <textarea name="content" id="content" cols="5" rows="5" class="form-control"> </textarea>
                    </div>
                        <div class="form-group">
                        <input type="submit" name="submit" value="Submit" class="btn btn-primary">
                    </div>
                </form>
              </div>

          </div>

@endsection PostController.php @extends('layouts.app')

@section('content')

<div class="card">
              <div class="card-header text-center">Edit Post : </div>

              <div class="card-body">
                  @if(count($errors)>0)

              <ul class="list-group alert">
                  @foreach($errors->all() as $error)
                  <li class="list-group-item text-danger">
                      
                  </li>

                  @endforeach
              </ul>

                  @endif

                <form action="" method="post" enctype="multipart/form-data">
                  
                    <div class="form-group">
                        <label for="title">Post Title</label>
                        <input type="text" name="title" placeholder="Enter" class="form-control" value=" ">
                    </div>
                    <div class="form-group">
                        <label for="image">Featured Image</label>
                        <input type="file" name="image" class="form-control">
                    </div>

                    <div class="form-group">
                        <label for="category">Select a Category</label>
                        <select name="category_id" id="category" class="form-control">
                          @foreach($categories as $cat)
                          <option value=""

                          @if($posts->cat->id== $cat->id) 
                            selected 
                          @endif

                            ></option>

                          @endforeach
                        </select>
                    </div>

                       <div class="form-group">
                        <label for="tag">Select Tags</label>
                  @foreach($tag as $tags)

                  <div class="checkbox">
                    <label><input type="checkbox" name="tags[]" value=""

                    @foreach($posts->tags as $t)

                  @if($tags->id==$t->id)
                  checked 

                  @endif
                    @endforeach
                      ></label>
                  </div>

                  @endforeach
                    </div>

                    <div class="form-group">
                        <label for="content">Description</label>
                        <textarea name="content" id="content" cols="5" rows="5" class="form-control"> </textarea>
                    </div>
                        <div class="form-group">
                        <input type="submit" name="submit" value="Submit" class="btn btn-primary">
                    </div>
                </form>
              </div>

          </div>

@endsection Trying to get property 'id' of non-object when I select category its not selected and show id is non-object



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2WWGXNi
via IFTTT

Aucun commentaire:

Enregistrer un commentaire