I would to CONCAT multiple column name(from different relations) using Model::with(relationships) way. How we can do that.
Level
id | name
1 | Admin
Permission
id | name
1 | All
User
id | level_id | permission_id | name
1 | 1 | 1 | Bob Login
I tried this way, but not working, I want this output Bob Login, Admin, All
User::with(['level','permission'])
->selectRaw("CONCATE (user.name, ', ', level.name,', ',permission.name) AS uname")
->list('uname','id')->all();
this way is working, but I dont want this one
DB::table('user AS u')
->join('level AS l','u.level_id','=','l.id')
->join('permission AS p','u.permission_id','=','p.id')
->selectRaw("CONCATE (user.name, ', ', level.name,', ',permission.name) AS uname")
->lists('uname','id');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire