Role.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Repositories\Models\Base;
  3. use Prettus\Repository\Contracts\Transformable;
  4. use Prettus\Repository\Traits\TransformableTrait;
  5. use Spatie\Permission\Traits\HasPermissions;
  6. /**
  7. * Class Role.
  8. *
  9. * @package namespace App\Repositories\Models\Base;
  10. */
  11. class Role extends \Spatie\Permission\Models\Role implements Transformable
  12. {
  13. use TransformableTrait;
  14. protected $table = 'base_roles';
  15. /**
  16. * The attributes that are mass assignable.
  17. *
  18. * @var array
  19. */
  20. protected $guarded = [];
  21. // protected static function booted()
  22. // {
  23. // self::language();
  24. // }
  25. public function setMenusAttribute($val)
  26. {
  27. if (count($val) == 0) return '';
  28. $this->attributes['menus'] = '-' . arr2str($val, '-') . '-';
  29. }
  30. public function getMenusAttribute($val)
  31. {
  32. return str2arr(trim($val, '-'), '-');
  33. }
  34. public function setParentMenusAttribute($val)
  35. {
  36. if (count($val) == 0) return '';
  37. $this->attributes['parent_menus'] = '-' . arr2str($val, '-') . '-';
  38. }
  39. public function getParentMenusAttribute($val)
  40. {
  41. return str2arr(trim($val, '-'), '-');
  42. }
  43. }