Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

tighten/novapackages

336 stars
3 code files
View tighten/novapackages on GitHub

app/Policies/HandlesPackageAuthorizationTrait.php

Open in GitHub
trait HandlesPackageAuthorizationTrait
{
protected function userIsAdminOrAuthorOrCollaboratorOrUnclaimedSubmitter($user, $package)
{
return $user->isAdmin()
|| $this->userIsPackageAuthor($user, $package)
|| $this->userIsPackageCollaborator($user, $package)
|| $this->userIsUnclaimedPackageSubmitter($user, $package);
}
}

app/Policies/PackagePolicy.php

Open in GitHub
use App\Package;
use App\Policies\HandlesPackageAuthorizationTrait;
 
class PackagePolicy
{
use HandlesPackageAuthorizationTrait;
 
public function show(User $user, Package $package)
{
return $this->userIsAdminOrAuthorOrCollaboratorOrUnclaimedSubmitter($user, $package);
}
 
public function update(User $user, Package $package)
{
return $this->userIsAdminOrAuthorOrCollaboratorOrUnclaimedSubmitter($user, $package);
}
}

app/Policies/ScreenshotPolicy.php

Open in GitHub
use App\Policies\HandlesPackageAuthorizationTrait;
use App\Screenshot;
use App\User;
 
class ScreenshotPolicy
{
use HandlesPackageAuthorizationTrait;
 
public function delete(User $user, Screenshot $screenshot)
{
if ($screenshot->uploader->is($user)
|| ($screenshot->hasPackage() && $this->userIsAdminOrAuthorOrCollaboratorOrUnclaimedSubmitter($user, $screenshot->package))
) {
return true;
}
 
return false;
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.