daniels
1 month ago
262
1
Laravel

Trying to get property of non-object - I just want some clarity here.

Posted 1 month ago by daniels

public function edit(User $user) { $roles = Role::all();

    return view('admin.users.edit', compact('user', 'roles')); THIS WORKS  

    return view('admin.users.edit')->with(['user' => '$user', 'roles' => '$roles']); THIS FAILS
}

on my view I have this

<div class="card-header">Edit User {{ $user->name }}</div>

I know I have resourced but have not gotten the workings so please just enlight me on why it happens so. am using laravel 7 windows 10 xampp

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