Skip to content

Commit

Permalink
Fix Activity log with premission
Browse files Browse the repository at this point in the history
  • Loading branch information
AlpetGexha committed Jun 25, 2023
1 parent 8aa16b6 commit 036f0d0
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 107 deletions.
100 changes: 0 additions & 100 deletions app/Filament/Pages/ListActivities.php

This file was deleted.

8 changes: 4 additions & 4 deletions app/Filament/Resources/CompanyInvitationResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('company.name'),
Tables\Columns\TextColumn::make('email'),
Tables\Columns\TextColumn::make('role'),
Tables\Columns\TextColumn::make('created_at')
->dateTime(),
->dateTime()
->sortable(),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
// Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
Expand All @@ -55,7 +55,7 @@ public static function getPages(): array
return [
'index' => Pages\ListCompanyInvitations::route('/'),
'create' => Pages\CreateCompanyInvitation::route('/create'),
'edit' => Pages\EditCompanyInvitation::route('/{record}/edit'),
// 'edit' => Pages\EditCompanyInvitation::route('/{record}/edit'),
];
}
}
133 changes: 133 additions & 0 deletions app/Policies/ActivityPolicy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?php

namespace App\Policies;

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

class ActivityPolicy
{
use HandlesAuthorization;

/**
* Determine whether the user can view any models.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function viewAny(User $user)
{
return $user->isSuperAdmin();
}

/**
* Determine whether the user can view the model.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function view(User $user)
{
return $user->isSuperAdmin();
}

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

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

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

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

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

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

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

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

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

/**
* Determine whether the user can reorder.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function reorder(User $user)
{
return $user->isSuperAdmin();
}
}
3 changes: 2 additions & 1 deletion app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class AuthServiceProvider extends ServiceProvider
PeriphelPolicy::class => Periphel::class,
ProvaiderPolicy::class => Provaider::class,
SoftwarePolicy::class => Software::class,
// Activity::class => ActivityPolicy::class,
Activity::class => ActivityPolicy::class

];

/**
Expand Down
4 changes: 2 additions & 2 deletions app/Traits/HasComapanyId.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ protected static function bootHasComapanyId()
}
});

if (! auth()->user()->isSuperAdmin()) {
// if (auth()->user()) {
static::addGlobalScope(new CompanyScope);
}
// }
}
}

0 comments on commit 036f0d0

Please sign in to comment.