Model User
https://github.com/slava-pleshkov/laravel-slavapleshkov/blob/master/app/User.php
Model Role
https://github.com/slava-pleshkov/laravel-slavapleshkov/blob/master/app/Role.php
Controllers User
https://github.com/slava-pleshkov/laravelslavapleshkov/blob/master/app/Http/Controllers/Admin/UserController.php
View
https://github.com/slava-pleshkov/laravel-slavapleshkov/blob/master/resources/views/admin/users/index.blade.php
Does not show in view.
Prompt me how I must decide a problem
The problem was solved.
The problem was solved.
Please post your solutions. Thanks.
Model User
public function role()
{
return $this->belongsTo('App\Role');
}
Model Role
public function users()
{
return $this->hasMany('App\User');
}
Controllers User
public function index()
{
$main = User::all();
return view('admin.users.index', compact('main'));
}
View
{{ $item->role->name }}
Most helpful comment
The problem was solved.