feat: initial commit

This commit is contained in:
JP
2024-08-05 08:04:35 +08:00
parent 0f3c3db73b
commit 140e821e0c
194 changed files with 14509 additions and 254 deletions

View File

@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Client;
use Illuminate\Auth\Access\HandlesAuthorization;
class ClientPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_client');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Client $client): bool
{
return $user->can('view_client');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_client');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Client $client): bool
{
return $user->can('update_client');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Client $client): bool
{
return $user->can('delete_client');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_client');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Client $client): bool
{
return $user->can('force_delete_client');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_client');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Client $client): bool
{
return $user->can('restore_client');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_client');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Client $client): bool
{
return $user->can('replicate_client');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_client');
}
}

108
app/Policies/RolePolicy.php Normal file
View File

@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use Spatie\Permission\Models\Role;
use Illuminate\Auth\Access\HandlesAuthorization;
class RolePolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_shield::role');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Role $role): bool
{
return $user->can('view_shield::role');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_shield::role');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Role $role): bool
{
return $user->can('update_shield::role');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Role $role): bool
{
return $user->can('delete_shield::role');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_shield::role');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Role $role): bool
{
return $user->can('{{ ForceDelete }}');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('{{ ForceDeleteAny }}');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Role $role): bool
{
return $user->can('{{ Restore }}');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('{{ RestoreAny }}');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Role $role): bool
{
return $user->can('{{ Replicate }}');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('{{ Reorder }}');
}
}

View File

@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Transmittal;
use Illuminate\Auth\Access\HandlesAuthorization;
class TransmittalPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_transmittal');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Transmittal $transmittal): bool
{
return $user->can('view_transmittal');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_transmittal');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Transmittal $transmittal): bool
{
return $user->can('update_transmittal');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Transmittal $transmittal): bool
{
return $user->can('delete_transmittal');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_transmittal');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Transmittal $transmittal): bool
{
return $user->can('force_delete_transmittal');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_transmittal');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Transmittal $transmittal): bool
{
return $user->can('restore_transmittal');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_transmittal');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Transmittal $transmittal): bool
{
return $user->can('replicate_transmittal');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_transmittal');
}
}

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

@@ -0,0 +1,144 @@
<?php
namespace App\Policies;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class UserPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*
* @param \App\Models\User $user
* @return bool
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_user');
}
/**
* Determine whether the user can view the model.
*
* @param \App\Models\User $user
* @return bool
*/
public function view(User $user): bool
{
return $user->can('view_user');
}
/**
* Determine whether the user can create models.
*
* @param \App\Models\User $user
* @return bool
*/
public function create(User $user): bool
{
return $user->can('create_user');
}
/**
* Determine whether the user can update the model.
*
* @param \App\Models\User $user
* @return bool
*/
public function update(User $user): bool
{
return $user->can('update_user');
}
/**
* Determine whether the user can delete the model.
*
* @param \App\Models\User $user
* @return bool
*/
public function delete(User $user): bool
{
return $user->can('delete_user');
}
/**
* Determine whether the user can bulk delete.
*
* @param \App\Models\User $user
* @return bool
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_user');
}
/**
* Determine whether the user can permanently delete.
*
* @param \App\Models\User $user
* @return bool
*/
public function forceDelete(User $user): bool
{
return $user->can('force_delete_user');
}
/**
* Determine whether the user can permanently bulk delete.
*
* @param \App\Models\User $user
* @return bool
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_user');
}
/**
* Determine whether the user can restore.
*
* @param \App\Models\User $user
* @return bool
*/
public function restore(User $user): bool
{
return $user->can('restore_user');
}
/**
* Determine whether the user can bulk restore.
*
* @param \App\Models\User $user
* @return bool
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_user');
}
/**
* Determine whether the user can bulk restore.
*
* @param \App\Models\User $user
* @return bool
*/
public function replicate(User $user): bool
{
return $user->can('replicate_user');
}
/**
* Determine whether the user can reorder.
*
* @param \App\Models\User $user
* @return bool
*/
public function reorder(User $user): bool
{
return $user->can('reorder_user');
}
}