orchidsoftware / orchidsoftware/platform

`byAccess` method returns empty collection but there are definitely users with provided permission

Open
#2,297 2 comments 2 reactions 1 assignee View on GitHub

@tabuna is already working on this.

Since Jul 4, 2022.

Errors
Dominant language
PHP
Stars
4.8k
Forks
663
Avg merge
1d 9h
Merged PRs (30d)
7

Description

Describe the bug
When I'm using

User::byAccess('projects.commit')->get();

I'm getting empty collection. At the same time this

User::find(1)->hasAccess('projects.commit'); 

return true.

While digging deeper I found out that if I change single line of scopeByAnyAccess method of UserAccess trait

// from
$builder->orWhere('permissions->'.$permit, true);

// to
$builder->orWhere('permissions->'.$permit, 1);

I'm getting my collection. Weird part that yesterday it worked fine, but I didn't know, what has been changed... I'm extending model so there is no big deal but I'm curios what may cause such problem and does changing true to 1 is a good solution?

Additional context
I'm using Laravel Sail with default Dockerfile for PHP 8.0

PHP version - 8.0.20
Laravel - 9.19.0
Orchid 12.6.2

Both Role and User models extended like

namespace App\Models;

use Orchid\Platform\Models\Role as OrchidRole;

class Role extends OrchidRole
{}

but there is nothing fancy

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.