Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. $user->permissions = array(
  2. 'read' => $data['read_permission'],
  3. 'comment' => ($data['write_permission'] >= 1 ? 1 : 0),
  4. 'edit' => ($data['write_permission'] >= 2 ? 1 : 0),
  5. 'edit_all' => '1'
  6. );
  7. $user->save();
  8.  
  9. protected $fillable = array('email', 'password', 'first_name', 'last_name', 'company_id', 'department_id', 'phone_number', 'phone_ext', 'permissions');
  10.  
  11. $permissions = array(
  12. 'read' => $data['read_permission'],
  13. 'comment' => ($data['write_permission'] >= 1 ? 1 : 0),
  14. 'edit' => ($data['write_permission'] >= 2 ? 1 : 0),
  15. 'edit_all' => '1'
  16. );
  17. DB::table('users')->where('id','=',$user->id)->update(['permissions' => json_encode($permissions)]);
  18.  
  19. $user->permissions = array(
  20. 'read' =>1,
  21. 'comment' => 1,
  22. 'edit' => 0,
  23. 'edit_all' => 0
  24. );
  25. $user->save();
  26.  
  27. $user->permissions = array(
  28. 'read' =>0,
  29. 'comment' => 0,
  30. 'edit' => 0,
  31. 'edit_all' => 0
  32. );
  33. $user->save();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement