如何在Laravel 5.8中写这个(左连接,然后打开)?

I cannot write my query in Laravel query builder, could help me?

I try to write but display many error.

select tb.id, `tb`.insert,
   `tb`.update,
   `tb`.delete,
   `tb`.list,
   `permissions`.`name`,
   `permissions`.`id` as permission_id
   from  `permissions`
   left join (select * from `role_permissions` where `role_permissions`.`role_id` = ' . $id . ') tb on `permissions`.id = tb.permission_id
        order by `permissions`.`id` asc'

As I wrote in my comment:

Line 8: you forgot to add the as behind the tb. Also, a subselect can only have one column returned from it, so you would need one subselect for each column that you would want returned from the model table.

Try to use this code here:

select tb.id,
    `tb`.insert,
    `tb`.update,
    `tb`.delete,
    `tb`.list,
    `ps`.`name`,
    `ps`.`id` as permission_id
    from  `permissions` as ps
    left join (select `permission_id` from `role_permissions` where `role_permissions`.`role_id` = ' . $id . ') as tb on `ps`.id = tb.permission_id
    order by `ps`.`id` asc'

This Code is for pure PHP. Laravel is using a "special" notation. How you can write a simple SQL Query in Laravel you can see here and here.