orchidsoftware / orchidsoftware/platform
`byAccess` method returns empty collection but there are definitely users with provided permission
@tabuna is already working on this.
Since Jul 4, 2022.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.