ViewException: Попытка получить свойство 'следует' не объекта - PullRequest
0 голосов
/ 29 апреля 2020

Я получаю исключение

Facade\Ignition\Exceptions\ViewException : Trying to get property 'follows' of non-object (View: E:\tweety\resources\views\_friends-lists.blade.php)

Из этого кода:

<h3 class="font-bold text-lg mb-4 block">Following</h3>
<ul>
  @foreach (auth()->user()->follows as $user)
    <li class="mb-2">
      <div class="flex items-center text-sm">
        <img src="{{ $user->avatar }}" alt="" class="rounded-full mr-2">{{ $user->name }}</div>
    </li>
  @endforeach
</ul>

1 Ответ

0 голосов
/ 29 апреля 2020
<h3 class="font-bold text-lg mb-4 block">Following</h3>
<ul>
    @foreach (DB::table("users")->where("follows",auth()->user()->id)->get() as $user)
        <li class="mb-2">
            <div class="flex items-center text-sm">
                <img src="{{ $user->avatar }}" alt="" class="rounded-full mr-2">{{ $user->name }}</div>
        </li>
    @endforeach
</ul>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...