I
I
igordata12020-06-30 10:34:02
Laravel
igordata1, 2020-06-30 10:34:02

How to fix Trying to get property 'title' of non-object error?

ErrorException (E_ERROR)
Trying to get property 'title' of non-object (View: /var/www/bossphp.x/resources/views/admin/categories/partials/form.blade.php) (View: /var/www /bossphp.x/resources/views/admin/categories/partials/form.blade.php)
Previous exceptions

Trying to get property 'title' of non-object (View: /var/www/bossphp.x/resources/views/ admin/categories/partials/form.blade.php) (0)
Trying to get property 'title' of non-object (0)

<label for="">Статус</label>
<select class="form-control" name="published">
    @if (isset($category->id))
        <option value="0" @if ($category->published == 0) selected="" @endif>Не опубликовано</option>
        <option value="1" @if ($category->published == 1) selected="" @endif>Опубликовано</option>
    @else
        <option value="0">Не опубликовано</option>
        <option value="1">Опубликовано</option>
    @endif
</select>

<label for="">Наименование</label>
<input type="text" class="form-control" name="title" placeholder="Заголовок категории" value="{{$category->title or ""}}" required>

<label for="">Slug</label>
<input class="form-control" type="text" name="slug" placeholder="Автоматическая генерация" value="{{$category->slug or ""}}" readonly="">

<label for="">Родительская категория</label>
<select class="form-control" name="parent_id">
    <option value="0">-- без родительской категории --</option>
    @include('admin.categories.partials.categories', ['categories' => $categories])
</select>

<hr />

<input class="btn btn-primary" type="submit" value="Сохранить">

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d-sem, 2020-06-30
@igordata1

$category->title or ""
Replaced by
$category->title ?? ''

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question