Laravel-mongodb: Does not work hasMany

Created on 13 Jun 2018  路  3Comments  路  Source: jenssegers/laravel-mongodb

Most helpful comment

The problem was solved.

All 3 comments

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 }}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Idnan picture Idnan  路  3Comments

bastiendonjon picture bastiendonjon  路  3Comments

sebastiaanluca picture sebastiaanluca  路  3Comments

ricardofontanelli picture ricardofontanelli  路  3Comments

YSimple picture YSimple  路  3Comments