Example #1
0
 private function applyPermissions($user, $data)
 {
     $user->actions()->delete();
     $keys = array_keys($data);
     foreach ($keys as $key) {
         if (starts_with($key, 'action_')) {
             $userAction = new UserAction();
             $userAction->user_id = $user->id;
             $userAction->action_id = substr(strrchr($key, "_"), 1);
             //the number following the prefix
             $userAction->save();
         }
     }
 }