wip
This commit is contained in:
101
app/Policies/CMS/Forms/ContactUSPolicy.php
Normal file
101
app/Policies/CMS/Forms/ContactUSPolicy.php
Normal 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();
|
||||
}
|
||||
}
|
||||
109
app/Policies/CMS/Marketing/NewsletterPolicy.php
Normal file
109
app/Policies/CMS/Marketing/NewsletterPolicy.php
Normal 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();
|
||||
}
|
||||
}
|
||||
109
app/Policies/CMS/Marketing/NewsletterUserPolicy.php
Normal file
109
app/Policies/CMS/Marketing/NewsletterUserPolicy.php
Normal 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();
|
||||
}
|
||||
}
|
||||
109
app/Policies/CMS/Media/BannerPolicy.php
Normal file
109
app/Policies/CMS/Media/BannerPolicy.php
Normal 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();
|
||||
}
|
||||
}
|
||||
109
app/Policies/CMS/Media/CarouselPolicy.php
Normal file
109
app/Policies/CMS/Media/CarouselPolicy.php
Normal 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();
|
||||
}
|
||||
}
|
||||
109
app/Policies/CMS/Media/GalleryPolicy.php
Normal file
109
app/Policies/CMS/Media/GalleryPolicy.php
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user