You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
865 B

  1. <?php
  2. namespace App\Utilities;
  3. use App\Models\User;
  4. use Illuminate\Support\Arr;
  5. use Jenssegers\Agent\Agent;
  6. /**
  7. * @mixin Request
  8. * Class RequestMixin
  9. */
  10. class BusinessInfoRequestMixin
  11. {
  12. public function getBusinessInfo()
  13. {
  14. return function () {
  15. return Arr::get($this, '_business_info');
  16. };
  17. }
  18. public function getFromBusinessInfo()
  19. {
  20. return function(string $key) {
  21. return Arr::get($this, "_business_info.$key");
  22. };
  23. }
  24. public function getBusinessUsers()
  25. {
  26. return function() {
  27. return $this->getFromBusinessInfo('info.users');
  28. };
  29. }
  30. public function isBusinessOwner()
  31. {
  32. return function(User $user) {
  33. return Arr::get($this, "_business_info.info.users.{$user->id}.level") != enum('levels.owner.id');
  34. };
  35. }
  36. }