SHARE
TWEET

Untitled

a guest Mar 20th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $previousOwners = $this->userRepo()->hasRoles(['Owner'])->pluck('id')->toArray();
  2. $newOwners = $this->clinic_owners;
  3. $deleted = array_diff($previousOwners, $newOwners);
  4. $new = array_diff($newOwners, $previousOwners);
  5.  
  6. foreach ($deleted as $id) {
  7.     $user = $this->userRepo->find($id);
  8.     $user->removeRole('Owner');
  9. }
  10.  
  11. foreach ($new as $id) {
  12.     $user = $this->userRepo->find($id);
  13.     $user->assignRole('Owner');
  14. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top