-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feature/button-and-input
- Loading branch information
Showing
14 changed files
with
613 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
enum Permissions: string | ||
{ | ||
// ACTIONS | ||
case BORROW = 'borrow'; | ||
case RESERVE = 'reserve'; | ||
case RETURN = 'return'; | ||
case LOGIN_MANAGE = 'login_manage'; | ||
|
||
// LIBRARY PASSES | ||
case VIEW_LIBRARY_PASS = 'view_library_pass'; | ||
case CREATE_LIBRARY_PASS = 'create_library_pass'; | ||
case EDIT_LIBRARY_PASS = 'edit_library_pass'; | ||
case DELETE_LIBRARY_PASS = 'delete_library_pass'; | ||
|
||
// ITEMS | ||
case VIEW_ITEM = 'view_item'; | ||
case CREATE_ITEM = 'create_item'; | ||
case EDIT_ITEM = 'edit_item'; | ||
case DELETE_ITEM = 'delete_item'; | ||
|
||
// USERS | ||
case VIEW_USER = 'view_user'; | ||
case CREATE_USER = 'create_user'; | ||
case EDIT_USER = 'edit_user'; | ||
case DELETE_USER = 'delete_user'; | ||
|
||
// GRANTS | ||
case VIEW_GRANT = 'view_grant'; | ||
case CREATE_GRANT = 'create_grant'; | ||
case EDIT_GRANT = 'edit_grant'; | ||
case DELETE_GRANT = 'delete_grant'; | ||
|
||
// RESERVATIONS | ||
case VIEW_RESERVATION = 'view_reservation'; | ||
case CREATE_RESERVATION = 'create_reservation'; | ||
case EDIT_RESERVATION = 'edit_reservation'; | ||
case DELETE_RESERVATION = 'delete_reservation'; | ||
|
||
// PAYMENTS | ||
case VIEW_PAYMENT = 'view_payment'; | ||
case CREATE_PAYMENT = 'create_payment'; | ||
case EDIT_PAYMENT = 'edit_payment'; | ||
|
||
// FINES | ||
case VIEW_FINE = 'view_fine'; | ||
CASE EDIT_FINE = 'manage_fine'; | ||
|
||
public function label(): string | ||
{ | ||
return match ($this) { | ||
|
||
static::BORROW => 'Borrow', | ||
static::RESERVE => 'Reserve', | ||
static::RETURN => 'Return', | ||
static::LOGIN_MANAGE => 'Login Manage', | ||
|
||
static::VIEW_LIBRARY_PASS => 'View Library Pass', | ||
static::CREATE_LIBRARY_PASS => 'Create Library Pass', | ||
static::EDIT_LIBRARY_PASS => 'Edit Library Pass', | ||
static::DELETE_LIBRARY_PASS => 'Delete Library Pass', | ||
|
||
static::VIEW_ITEM => 'View Item', | ||
static::CREATE_ITEM => 'Create Item', | ||
static::EDIT_ITEM => 'Edit Item', | ||
static::DELETE_ITEM => 'Delete Item', | ||
|
||
static::VIEW_USER => 'View User', | ||
static::CREATE_USER => 'Create User', | ||
static::DELETE_USER => 'Delete User', | ||
|
||
static::VIEW_GRANT => 'View Grant', | ||
static::CREATE_GRANT => 'Create Grant', | ||
static::EDIT_GRANT => 'Edit Grant', | ||
static::DELETE_GRANT => 'Delete Grant', | ||
|
||
static::VIEW_RESERVATION => 'View Reservation', | ||
static::CREATE_RESERVATION => 'Create Reservation', | ||
static::EDIT_RESERVATION => 'Edit Reservation', | ||
static::DELETE_RESERVATION => 'Delete Reservation', | ||
|
||
static::VIEW_PAYMENT => 'View Payment', | ||
static::CREATE_PAYMENT => 'Create Payment', | ||
static::EDIT_PAYMENT => 'Edit Payment', | ||
|
||
static::VIEW_FINE => 'View Fine', | ||
static::EDIT_FINE => 'Manage Fine', | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
enum Roles: string | ||
{ | ||
case SUPERADMIN = 'super_admin'; | ||
case COLLEAGUE = 'colleague'; | ||
case CUSTOMER = 'customer'; | ||
|
||
public function label(): string | ||
{ | ||
return match ($this) { | ||
static::SUPERADMIN => 'Super Admin', | ||
static::COLLEAGUE => 'Colleague', | ||
static::CUSTOMER => 'Customer', | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use App\Enums\Permissions; | ||
use App\Enums\Roles; | ||
use Illuminate\Database\Console\Seeds\WithoutModelEvents; | ||
use Illuminate\Database\Seeder; | ||
use Spatie\Permission\Models\Permission; | ||
use Spatie\Permission\Models\Role; | ||
|
||
class PermissionSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
*/ | ||
public function run(): void | ||
{ | ||
// Create all roles | ||
$superAdmin = Role::create(['name' => Roles::SUPERADMIN]); | ||
$colleague = Role::create(['name' => Roles::COLLEAGUE]); | ||
$customer = Role::create(['name' => Roles::CUSTOMER]); | ||
|
||
// Create all permissions | ||
|
||
$borrow = Permission::create(['name' => Permissions::BORROW]); | ||
$reserve = Permission::create(['name' => Permissions::RESERVE]); | ||
$return = Permission::create(['name' => Permissions::RETURN]); | ||
$loginManage = Permission::create(['name' => Permissions::LOGIN_MANAGE]); | ||
|
||
$viewLibraryPass = Permission::create(['name' => Permissions::VIEW_LIBRARY_PASS]); | ||
$createLibraryPass = Permission::create(['name' => Permissions::CREATE_LIBRARY_PASS]); | ||
$editLibraryPass = Permission::create(['name' => Permissions::EDIT_LIBRARY_PASS]); | ||
$deleteLibraryPass = Permission::create(['name' => Permissions::DELETE_LIBRARY_PASS]); | ||
|
||
$viewItem = Permission::create(['name' => Permissions::VIEW_ITEM]); | ||
$createItem = Permission::create(['name' => Permissions::CREATE_ITEM]); | ||
$editItem = Permission::create(['name' => Permissions::EDIT_ITEM]); | ||
$deleteItem = Permission::create(['name' => Permissions::DELETE_ITEM]); | ||
|
||
$viewUser = Permission::create(['name' => Permissions::VIEW_USER]); | ||
$createUser = Permission::create(['name' => Permissions::CREATE_USER]); | ||
$editUser = Permission::create(['name' => Permissions::EDIT_USER]); | ||
$deleteUser = Permission::create(['name' => Permissions::DELETE_USER]); | ||
|
||
$viewGrant = Permission::create(['name' => Permissions::VIEW_GRANT]); | ||
$createGrant = Permission::create(['name' => Permissions::CREATE_GRANT]); | ||
$editGrant = Permission::create(['name' => Permissions::EDIT_GRANT]); | ||
$deleteGrant = Permission::create(['name' => Permissions::DELETE_GRANT]); | ||
|
||
$viewReservation = Permission::create(['name' => Permissions::VIEW_RESERVATION]); | ||
$createReservation = Permission::create(['name' => Permissions::CREATE_RESERVATION]); | ||
$editReservation = Permission::create(['name' => Permissions::EDIT_RESERVATION]); | ||
$deleteReservation = Permission::create(['name' => Permissions::DELETE_RESERVATION]); | ||
|
||
$viewPayment = Permission::create(['name' => Permissions::VIEW_PAYMENT]); | ||
$createPayment = Permission::create(['name' => Permissions::CREATE_PAYMENT]); | ||
$editPayment = Permission::create(['name' => Permissions::EDIT_PAYMENT]); | ||
|
||
$viewFine = Permission::create(['name' => Permissions::VIEW_FINE]); | ||
$editFine = Permission::create(['name' => Permissions::EDIT_FINE]); | ||
|
||
|
||
|
||
// -- CUSTOMER | ||
$customer->givePermissionTo($borrow); | ||
$customer->givePermissionTo($reserve); | ||
$customer->givePermissionTo($return); | ||
|
||
// -- COLLEAGUE | ||
$colleague->givePermissionTo($borrow); | ||
$colleague->givePermissionTo($reserve); | ||
$colleague->givePermissionTo($return); | ||
$colleague->givePermissionTo($loginManage); | ||
|
||
$colleague->givePermissionTo($viewLibraryPass); | ||
$colleague->givePermissionTo($createLibraryPass); | ||
$colleague->givePermissionTo($editLibraryPass); | ||
$colleague->givePermissionTo($deleteLibraryPass); | ||
|
||
$colleague->givePermissionTo($viewItem); | ||
$colleague->givePermissionTo($createItem); | ||
$colleague->givePermissionTo($editItem); | ||
$colleague->givePermissionTo($deleteItem); | ||
|
||
$colleague->givePermissionTo($viewUser); | ||
$colleague->givePermissionTo($createUser); | ||
$colleague->givePermissionTo($editUser); | ||
$colleague->givePermissionTo($deleteUser); | ||
|
||
$colleague->givePermissionTo($viewGrant); | ||
$colleague->givePermissionTo($createGrant); | ||
$colleague->givePermissionTo($editGrant); | ||
$colleague->givePermissionTo($deleteGrant); | ||
|
||
$colleague->givePermissionTo($viewReservation); | ||
$colleague->givePermissionTo($createReservation); | ||
$colleague->givePermissionTo($editReservation); | ||
$colleague->givePermissionTo($deleteReservation); | ||
|
||
$colleague->givePermissionTo($viewPayment); | ||
$colleague->givePermissionTo($viewFine); | ||
} | ||
} |
Oops, something went wrong.