RoleLogic.php 939 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/4/29 0029
  6. * Time: 17:16
  7. */
  8. namespace App\Http\Logics\Admin;
  9. use App\Http\Models\LinkTask;
  10. use App\Http\Models\LinkTaskDetail;
  11. use App\Http\Models\LinkTaskUrl;
  12. use App\Http\Models\Permission;
  13. use App\Http\Models\Role;
  14. use App\Http\Models\User;
  15. use \Illuminate\Database\Eloquent\Builder;
  16. use Illuminate\Http\Request;
  17. use Illuminate\Support\Facades\Auth;
  18. use Illuminate\Support\Facades\DB;
  19. class RoleLogic
  20. {
  21. const Customer_Permissions = [21, 22, 23, 26, 32, 33, 34, 35, 36, 39, 40, 144, 145, 220, 221, 222, 223, 344, 345, 356, 357,384];
  22. public function getRoleCanPermissions($role)
  23. {
  24. $builder = Permission::query()->select(['title as name', 'id', 'parent_id', 'type']);
  25. if ($role->id == Role::TYPE_CUSTOMER) {
  26. $builder->whereIn('id', self::Customer_Permissions);
  27. }
  28. return $builder->get()->toArray();
  29. }
  30. }