This commit is contained in:
2026-02-03 15:31:29 +05:00
commit 326c677e8d
2800 changed files with 1489388 additions and 0 deletions

View File

@@ -0,0 +1,101 @@
<?php
namespace App\Policies\CMS\Forms;
use App\Models\CMS\Forms\ContactUS;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class ContactUSPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, ContactUS $contactUS): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, ContactUS $contactUS): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, ContactUS $contactUS): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, ContactUS $contactUS): Response
{
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, ContactUS $contactUS): Response
{
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\CMS\Marketing;
use App\Models\CMS\Marketing\Newsletter;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class NewsletterPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Newsletter $newsletter): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Newsletter $newsletter): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Newsletter $newsletter): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Newsletter $newsletter): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Newsletter $newsletter): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\CMS\Marketing;
use App\Models\CMS\Marketing\NewsletterUser;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class NewsletterUserPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, NewsletterUser $newsletterUser): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, NewsletterUser $newsletterUser): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, NewsletterUser $newsletterUser): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, NewsletterUser $newsletterUser): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, NewsletterUser $newsletterUser): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\CMS\Media;
use App\Models\CMS\Media\Banner;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class BannerPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Banner $banner): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Banner $banner): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Banner $banner): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Banner $banner): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Banner $banner): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\CMS\Media;
use App\Models\CMS\Media\Carousel;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class CarouselPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Carousel $carousel): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Carousel $carousel): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Carousel $carousel): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Carousel $carousel): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Carousel $carousel): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\CMS\Media;
use App\Models\CMS\Media\Gallery;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class GalleryPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Gallery $gallery): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Gallery $gallery): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Gallery $gallery): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Gallery $gallery): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Gallery $gallery): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,113 @@
<?php
namespace App\Policies\Ecommerce\Channel;
use App\Models\Ecommerce\Channel\Channel;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class ChannelPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Channel $channel): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Channel $channel): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Channel $channel): Response
{
if (tmpostChannel()->slug === $channel->slug) {
return $this->deny();
}
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Channel $channel): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Channel $channel): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\Ecommerce\Payout;
use App\Models\Ecommerce\Payouts\Payout;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class PayoutPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Payout $payout): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Payout $payout): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Payout $payout): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Payout $payout): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Payout $payout): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\Ecommerce\Product\Brand;
use App\Models\Ecommerce\Product\Brand\Brand;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class BrandPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin', 'vendor'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Brand $brand): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Brand $brand): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Brand $brand): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Brand $brand): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Brand $brand): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,113 @@
<?php
namespace App\Policies\Ecommerce\Product\Category;
use App\Models\Ecommerce\Product\Category\Category;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class CategoryPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
if ($user->hasRole('vendor')) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Category $category): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Category $category): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Category $category): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Category $category): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Category $category): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,113 @@
<?php
namespace App\Policies\Ecommerce\Product\Collection;
use App\Models\Ecommerce\Product\Collection\Collection;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class CollectionPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
if ($user->hasRole(['vendor'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Collection $collection): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Collection $collection): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Collection $collection): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Collection $collection): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Collection $collection): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\Ecommerce\Product\Coupon;
use App\Models\Ecommerce\Product\Coupon\Coupon;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class CouponPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Coupon $coupon): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Coupon $coupon): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Coupon $coupon): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Coupon $coupon): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Coupon $coupon): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,121 @@
<?php
namespace App\Policies\Ecommerce\Product\Inventory;
use App\Models\Ecommerce\Product\Inventory\Inventory;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class InventoryPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin', 'vendor'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Inventory $inventory): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
if ($user->hasRole('vendor') && $user->ownsInventory($inventory)) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
if ($user->hasRole('vendor') && $user->doesntOwnInventory()) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Inventory $inventory): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
if ($user->hasRole('vendor') && $user->ownsInventory($inventory)) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Inventory $inventory): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Inventory $inventory): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Inventory $inventory): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\Ecommerce\Product\Order;
use App\Models\Ecommerce\Product\Order\OrderItem;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class OrderItemPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin', 'manager', 'vendor'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, OrderItem $orderItem): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, OrderItem $orderItem): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, OrderItem $orderItem): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, OrderItem $orderItem): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, OrderItem $orderItem): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\Ecommerce\Product\Order;
use App\Models\Ecommerce\Product\Order\Order;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class OrderPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin', 'manager', 'vendor'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Order $order): Response
{
if ($user->hasRole(['admin', 'vendor'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Order $order): Response
{
if ($user->hasRole(['admin', 'vendor'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Order $order): Response
{
if ($user->hasRole(['admin', 'vendor'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Order $order): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Order $order): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,121 @@
<?php
namespace App\Policies\Ecommerce\Product\Product;
use App\Models\Ecommerce\Product\Product\Product;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class ProductPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin', 'manager', 'vendor'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Product $product): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
if ($user->hasRole('vendor') && $user->ownsProduct($product)) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin', 'vendor'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Product $product): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
if ($user->hasRole('vendor') && $user->ownsProduct($product)) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Product $product): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
if ($user->hasRole('vendor') && $user->ownsProduct($product)) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Product $product): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Product $product): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,116 @@
<?php
namespace App\Policies\Ecommerce\Product\Property;
use App\Models\Ecommerce\Product\Property\Attribute;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class AttributePolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin', 'vendor'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Attribute $attribute): Response
{
if ($user->hasRole(['admin', 'vendor'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole('admin')) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Attribute $attribute): Response
{
if ($user->hasRole('admin')) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Attribute $attribute): Response
{
if (in_array($attribute->slug, [
'size',
'colour',
])) {
return $this->deny();
}
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Attribute $attribute): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Attribute $attribute): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\Ecommerce\Product\Review;
use App\Models\Ecommerce\Product\Review\Review;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class ReviewPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Review $review): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Review $review): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Review $review): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Review $review): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Review $review): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\Legal;
use App\Models\Legal\LegalPage;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class LegalPagePolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, LegalPage $legalPage): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, LegalPage $legalPage): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, LegalPage $legalPage): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, LegalPage $legalPage): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, LegalPage $legalPage): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\Post;
use App\Models\Post\PostBranch;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class PostBranchPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, PostBranch $postBranch): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, PostBranch $postBranch): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, PostBranch $postBranch): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, PostBranch $postBranch): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, PostBranch $postBranch): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\System\Roles;
use App\Models\System\Roles\Permission;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class PermissionPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Permission $permission): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Permission $permission): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Permission $permission): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Permission $permission): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Permission $permission): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\System\Roles;
use App\Models\System\Roles\Role;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class RolePolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Role $role): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Role $role): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Role $role): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Role $role): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Role $role): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\System\Settings\Location;
use App\Models\System\Settings\Location\Province;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class ProvincePolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Province $province): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Province $province): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Province $province): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Province $province): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Province $province): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace App\Policies\System\Settings\Payments;
use App\Models\System\Settings\Payments\PaymentType;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class PaymentTypePolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, PaymentType $paymentType): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, PaymentType $paymentType): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, PaymentType $paymentType): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, PaymentType $paymentType): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, PaymentType $paymentType): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}

View File

@@ -0,0 +1,101 @@
<?php
namespace App\Policies\System\VersionManagement;
use App\Models\System\VersionManagement\AppVersion;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class AppVersionPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe()) {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, AppVersion $appVersion): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, AppVersion $appVersion): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, AppVersion $appVersion): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, AppVersion $appVersion): Response
{
//
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, AppVersion $appVersion): Response
{
//
}
}

124
app/Policies/UserPolicy.php Normal file
View File

@@ -0,0 +1,124 @@
<?php
namespace App\Policies;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
class UserPolicy
{
use HandlesAuthorization;
/**
* Perform pre-authorization checks.
*/
public function before(User $user, string $ability): ?Response
{
if ($user->isMe() && $ability !== 'delete') {
return $this->allow();
}
return null;
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): Response
{
if ($user->hasRole(['admin', 'manager'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, User $model): Response
{
if ($model->isMe()) {
return $this->deny();
}
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, User $model): Response
{
if ($model->isMe()) {
return $this->deny();
}
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, User $model): Response
{
if ($model->isMe()) {
return $this->deny();
}
if ($user->isMe()) {
return $this->allow();
}
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, User $model): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, User $model): Response
{
if ($user->hasRole(['admin'])) {
return $this->allow();
}
return $this->deny();
}
}