Skip to content

Commit

Permalink
Update ActivityPolicy.php
Browse files Browse the repository at this point in the history
  • Loading branch information
AlpetGexha committed Jun 25, 2023
1 parent 6f9912a commit 18c8bae
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions app/Policies/ActivityPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
namespace App\Policies;

use App\Models\User;
use App\Models\Provaider;
use Illuminate\Auth\Access\HandlesAuthorization;
use Spatie\Activitylog\Models\Activity;
use Illuminate\Auth\Access\HandlesAuthorization;

class ActivityPolicy
{
Expand All @@ -14,120 +13,138 @@ class ActivityPolicy
/**
* Determine whether the user can view any models.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
*/
public function viewAny(User $user)
{
return $user->isSuperAdmin();
return $user->can('view_any_activity') || $user->isSuperAdmin();
}

/**
* Determine whether the user can view the model.
*
* @param \App\Models\User $user
* @param \Spatie\Activitylog\Models\Activity $activity
* @return \Illuminate\Auth\Access\Response|bool
*/
public function view(User $user)
public function view(User $user, Activity $activity)
{
return $user->isSuperAdmin();
return $user->can('view_activity') || $user->isSuperAdmin();
}

/**
* Determine whether the user can create models.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
*/
public function create(User $user)
{
return $user->isSuperAdmin();
return $user->can('create_activity') || $user->isSuperAdmin();
}

/**
* Determine whether the user can update the model.
*
* @param \App\Models\User $user
* @param \Spatie\Activitylog\Models\Activity $activity
* @return \Illuminate\Auth\Access\Response|bool
*/
public function update(User $user, Activity $activity)
{
return $user->isSuperAdmin();
return $user->can('update_activity') || $user->isSuperAdmin();
}

/**
* Determine whether the user can delete the model.
*
* @param \App\Models\User $user
* @param \Spatie\Activitylog\Models\Activity $activity
* @return \Illuminate\Auth\Access\Response|bool
*/
public function delete(User $user, Activity $activity)
{
return $user->isSuperAdmin();
return $user->can('delete_activity') || $user->isSuperAdmin();
}

/**
* Determine whether the user can bulk delete.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
*/
public function deleteAny(User $user)
{
return $user->isSuperAdmin();
return $user->can('delete_any_activity') || $user->isSuperAdmin();
}

/**
* Determine whether the user can permanently delete.
*
* @param \App\Models\User $user
* @param \Spatie\Activitylog\Models\Activity $activity
* @return \Illuminate\Auth\Access\Response|bool
*/
public function forceDelete(User $user, Activity $activity)
{
return $user->isSuperAdmin();
return $user->can('force_delete_activity') || $user->isSuperAdmin();
}

/**
* Determine whether the user can permanently bulk delete.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
*/
public function forceDeleteAny(User $user)
{
return $user->isSuperAdmin();
return $user->can('force_delete_any_activity') || $user->isSuperAdmin();
}

/**
* Determine whether the user can restore.
*
* @param \App\Models\User $user
* @param \Spatie\Activitylog\Models\Activity $activity
* @return \Illuminate\Auth\Access\Response|bool
*/
public function restore(User $user, Activity $activity)
{
return $user->isSuperAdmin();
return $user->can('restore_activity') || $user->isSuperAdmin();
}

/**
* Determine whether the user can bulk restore.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
*/
public function restoreAny(User $user)
{
return $user->isSuperAdmin();
return $user->can('restore_any_activity') || $user->isSuperAdmin();
}

/**
* Determine whether the user can replicate.
*
* @param \App\Models\User $user
* @param \Spatie\Activitylog\Models\Activity $activity
* @return \Illuminate\Auth\Access\Response|bool
*/
public function replicate(User $user, Activity $activity)
{
return $user->isSuperAdmin();
return $user->can('replicate_activity') || $user->isSuperAdmin();
}

/**
* Determine whether the user can reorder.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
*/
public function reorder(User $user)
{
return $user->isSuperAdmin();
return $user->can('reorder_activity') || $user->isSuperAdmin();
}
}

0 comments on commit 18c8bae

Please sign in to comment.