Skip to content

Commit

Permalink
Merge pull request #911 from JoshKisb/main
Browse files Browse the repository at this point in the history
shield
  • Loading branch information
curtisdelicata authored Aug 20, 2024
2 parents 9b99480 + ede04b1 commit e221cbd
Show file tree
Hide file tree
Showing 49 changed files with 13,839 additions and 523 deletions.
2 changes: 1 addition & 1 deletion app/Actions/Fortify/CreateNewUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function create(array $input): User
$team = $this->createTeam($user);
$user->switchTeam($team);
setPermissionsTeamId($team->id);
$user->assignRole('free');
// $user->assignRole('panel_user');
});
});
}
Expand Down
60 changes: 0 additions & 60 deletions app/Filament/App/Resources/DatabaseResource.php

This file was deleted.

3 changes: 2 additions & 1 deletion app/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Spatie\Permission\Models\Role as SpatieRole;

class Role extends Model
class Role extends SpatieRole
{
public function team(): BelongsTo
{
Expand Down
7 changes: 2 additions & 5 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Models;

use BezhanSalleh\FilamentShield\Traits\HasPanelShield;
use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasDefaultTenant;
use Filament\Models\Contracts\HasTenants;
Expand Down Expand Up @@ -34,6 +35,7 @@ class User extends Authenticatable implements HasDefaultTenant, HasTenants, Fila
use SetsProfilePhotoFromUrl;
use TwoFactorAuthenticatable;
use HasTeams;
use HasPanelShield;

/**
* The attributes that are mass assignable.
Expand Down Expand Up @@ -102,11 +104,6 @@ public function canAccessTenant(Model $tenant): bool
return true; //$this->ownedTeams->contains($tenant);
}

public function canAccessPanel(Panel $panel): bool
{
return true;//$this->hasRole('admin');
}

public function canAccessFilament(): bool
{
// return $this->hasVerifiedEmail();
Expand Down
66 changes: 54 additions & 12 deletions app/Policies/AddrPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,107 @@

namespace App\Policies;

use App\Models\Addr;
use App\Models\User;
use App\Models\Addr;
use Illuminate\Auth\Access\HandlesAuthorization;

class AddrPolicy
{
use HandlesAuthorization;

/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
// dd($user->getAllPermissions());
return $user->checkPermissionTo('view-any Addr');
return $user->can('view_any_addr');
}

/**
* Determine whether the user can view the model.
*/
public function view(User $user, Addr $addr): bool
{
return $user->checkPermissionTo('view Addr');
return $user->can('view_addr');
}

/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->checkPermissionTo('create Addr');
return $user->can('create_addr');
}

/**
* Determine whether the user can update the model.
*/
public function update(User $user, Addr $addr): bool
{
return $user->checkPermissionTo('update Addr');
return $user->can('update_addr');
}

/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Addr $addr): bool
{
return $user->checkPermissionTo('delete Addr');
return $user->can('delete_addr');
}

/**
* Determine whether the user can restore the model.
* Determine whether the user can bulk delete.
*/
public function restore(User $user, Addr $addr): bool
public function deleteAny(User $user): bool
{
return $user->checkPermissionTo('restore Addr');
return $user->can('delete_any_addr');
}

/**
* Determine whether the user can permanently delete the model.
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Addr $addr): bool
{
return $user->checkPermissionTo('force-delete Addr');
return $user->can('force_delete_addr');
}

/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_addr');
}

/**
* Determine whether the user can restore.
*/
public function restore(User $user, Addr $addr): bool
{
return $user->can('restore_addr');
}

/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_addr');
}

/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Addr $addr): bool
{
return $user->can('replicate_addr');
}

/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_addr');
}
}
65 changes: 54 additions & 11 deletions app/Policies/AuthorPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,107 @@

namespace App\Policies;

use App\Models\Author;
use App\Models\User;
use App\Models\Author;
use Illuminate\Auth\Access\HandlesAuthorization;

class AuthorPolicy
{
use HandlesAuthorization;

/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->checkPermissionTo('view-any Author');
return $user->can('view_any_author');
}

/**
* Determine whether the user can view the model.
*/
public function view(User $user, Author $author): bool
{
return $user->checkPermissionTo('view Author');
return $user->can('view_author');
}

/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->checkPermissionTo('create Author');
return $user->can('create_author');
}

/**
* Determine whether the user can update the model.
*/
public function update(User $user, Author $author): bool
{
return $user->checkPermissionTo('update Author');
return $user->can('update_author');
}

/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Author $author): bool
{
return $user->checkPermissionTo('delete Author');
return $user->can('delete_author');
}

/**
* Determine whether the user can restore the model.
* Determine whether the user can bulk delete.
*/
public function restore(User $user, Author $author): bool
public function deleteAny(User $user): bool
{
return $user->checkPermissionTo('restore Author');
return $user->can('delete_any_author');
}

/**
* Determine whether the user can permanently delete the model.
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Author $author): bool
{
return $user->checkPermissionTo('force-delete Author');
return $user->can('force_delete_author');
}

/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_author');
}

/**
* Determine whether the user can restore.
*/
public function restore(User $user, Author $author): bool
{
return $user->can('restore_author');
}

/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_author');
}

/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Author $author): bool
{
return $user->can('replicate_author');
}

/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_author');
}
}
Loading

0 comments on commit e221cbd

Please sign in to comment.