am试图遍历数组$permission_ids
以获取值68
并将其分配给$manager_role
并将此值存储在表permissions
中,但是此块代码不能做到这一点?
我在哪里出错了?
**
foreach ($permission_ids as $permission_id) {
if($permission_id = 68){
// attach manager role permission to manager role
$manager_role->permissions()->attach($permission_id);
}
}
**
答案 0 :(得分:1)
我认为@Hoppo的注释是正确的,您弄错了等号运算符,请使用==
而不是=
:
foreach ($permission_ids as $permission_id) {
if($permission_id == 68){
// attach manager role permission to manager role
$manager_role->permissions()->attach($permission_id);
}
}