Raindrops
322
10
Laravel

Trying to get property of non-object

Posted 2 years ago by Raindrops

In my controller:

$users = User::where('id', '!=', Auth::id())->pluck('username', 'id');

In my view:

                    @foreach($users as $user)
                        <option value="{{ $user->id }}">{{ $user->username }}</option>
                    @endforeach 

This gives me Trying to get property of non-object error in the view, but this one works

{{ Form::select('s', $users, null, ['class' => 'form-control']) }}

Any idea what's causing it?

Please sign in or create an account to participate in this conversation.