Nice job, I've been liking these kind of posts you've been doing lately, and your final function is way better.
However, I feel like playing along, too. How about this? :)
<?php function canView(string $scope, int $owner_id): bool { return $scope === 'public' || $this->userCanView(Auth::user(), $owner_id); } function userCanView(User $user, int $owner_id): bool { return $user->hasRole('admin') || $user->id === $owner_id; }
I don't know the context, but I'm pretty sure it doesn't even matter if the $scope is 'private', if the current user is the owner.
$scope
'private'
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice job, I've been liking these kind of posts you've been doing lately, and your final function is way better.
However, I feel like playing along, too. How about this? :)
I don't know the context, but I'm pretty sure it doesn't even matter if the
$scope
is'private'
, if the current user is the owner.