Lager-v3/app/Providers/AuthServiceProvider.php

223 lines
12 KiB
PHP

<?php
namespace App\Providers;
// use Illuminate\Support\Facades\Gate;
use App\Models\Brand;
use App\Models\Building;
use App\Models\Cabel;
use App\Models\Cabelcategory;
use App\Models\Note;
use App\Models\Product;
use App\Models\ProductCategory;
use App\Models\ProductModel;
use App\Models\ProductSubcategory;
use App\Models\Role;
use App\Models\Room;
use App\Models\User;
use App\Policies\BrandPolicy;
use App\Policies\BuildingPolicy;
use App\Policies\CabelcategoryPolicy;
use App\Policies\CabelPolicy;
use App\Policies\CategoryPolicy;
use App\Policies\LoanPolicy;
use App\Policies\ModelPolicy;
use App\Policies\NotePolicy;
use App\Policies\OtherPolicy;
use App\Policies\PDFPolicy;
use App\Policies\ProductPolicy;
use App\Policies\ReservationPolicy;
use App\Policies\RolePolicy;
use App\Policies\RoomPolicy;
use App\Policies\SubcategoryPolicy;
use App\Policies\UserPolicy;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
// 'App\Models\models' => 'App\Policies\ModelPolicy',
Role::class => RolePolicy::class,
User::class => UserPolicy::class,
Building::class => BuildingPolicy::class,
Room::class => RoomPolicy::class,
Brand::class => BrandPolicy::class,
ProductModel::class => ModelPolicy::class,
ProductCategory::class => CategoryPolicy::class,
ProductSubcategory::class => SubcategoryPolicy::class,
Product::class => ProductPolicy::class,
Cabel::class => CabelPolicy::class,
Cabelcategory::class => CabelcategoryPolicy::class,
Note::class => NotePolicy::class,
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
// users Policy
Gate::define('users_viewAny', [UserPolicy::class,'viewAny']);
Gate::define('users_viewAny_deleted', [UserPolicy::class,'viewAny_deleted']);
Gate::define('users_view', [UserPolicy::class,'view']);
Gate::define('users_edit', [UserPolicy::class,'edit']);
Gate::define('users_edit_role', [UserPolicy::class,'edit_role']);
Gate::define('users_edit_username', [UserPolicy::class,'edit_username']);
Gate::define('users_delete', [UserPolicy::class,'delete']);
Gate::define('users_delete_force', [UserPolicy::class,'delete_force']);
Gate::define('users_restore', [UserPolicy::class,'restore']);
// buildings Policy
Gate::define('buildings_viewAny', [BuildingPolicy::class,'viewAny']);
Gate::define('buildings_viewAny_deleted', [BuildingPolicy::class,'viewAny_deleted']);
Gate::define('buildings_view', [BuildingPolicy::class,'view']);
Gate::define('buildings_create', [BuildingPolicy::class,'create']);
Gate::define('buildings_edit', [BuildingPolicy::class,'edit']);
Gate::define('buildings_delete', [BuildingPolicy::class,'delete']);
Gate::define('buildings_delete_force', [BuildingPolicy::class,'delete_force']);
Gate::define('buildings_restore', [BuildingPolicy::class,'restore']);
// rooms Policy
Gate::define('rooms_viewAny', [RoomPolicy::class,'viewAny']);
Gate::define('rooms_viewAny_deleted', [RoomPolicy::class,'viewAny_deleted']);
Gate::define('rooms_view', [RoomPolicy::class,'view']);
Gate::define('rooms_create', [RoomPolicy::class,'create']);
Gate::define('rooms_edit', [RoomPolicy::class,'edit']);
Gate::define('rooms_delete', [RoomPolicy::class,'delete']);
Gate::define('rooms_delete_force', [RoomPolicy::class,'delete_force']);
Gate::define('rooms_restore', [RoomPolicy::class,'restore']);
//PDF
Gate::define('pdf_viewAny',[PDFPolicy::class,'viewAny']);
Gate::define('pdf_view',[PDFPolicy::class,'view']);
Gate::define('pdf_delete',[PDFPolicy::class,'delete']);
// roles Policy
Gate::define('roles_viewAny', [RolePolicy::class, 'viewAny']);
Gate::define('roles_viewAny_deleted', [RolePolicy::class, 'viewAny_deleted']);
Gate::define('roles_view', [RolePolicy::class, 'view']);
Gate::define('roles_create', [RolePolicy::class, 'create']);
Gate::define('roles_edit', [RolePolicy::class, 'edit']);
Gate::define('roles_edit_permissions', [RolePolicy::class, 'edit_permissions']);
Gate::define('roles_delete', [RolePolicy::class, 'delete']);
Gate::define('roles_delete_force', [RolePolicy::class, 'delete_force']);
Gate::define('roles_restore', [RolePolicy::class, 'restore']);
// brands Policy
Gate::define('brands_viewAny', [BrandPolicy::class, 'viewAny']);
Gate::define('brands_viewAny_deleted', [BrandPolicy::class, 'viewAny_deleted']);
Gate::define('brands_view', [BrandPolicy::class, 'view']);
Gate::define('brands_create', [BrandPolicy::class, 'create']);
Gate::define('brands_edit', [BrandPolicy::class, 'edit']);
Gate::define('brands_delete', [BrandPolicy::class, 'delete']);
Gate::define('brands_delete_force', [BrandPolicy::class, 'delete_force']);
Gate::define('brands_restore', [BrandPolicy::class, 'restore']);
// models Policy
Gate::define('models_viewAny', [ModelPolicy::class, 'viewAny']);
Gate::define('models_viewAny_deleted', [ModelPolicy::class, 'viewAny_deleted']);
Gate::define('models_view', [ModelPolicy::class, 'view']);
Gate::define('models_create', [ModelPolicy::class, 'create']);
Gate::define('models_edit', [ModelPolicy::class, 'edit']);
Gate::define('models_delete', [ModelPolicy::class, 'delete']);
Gate::define('models_delete_force', [ModelPolicy::class, 'delete_force']);
Gate::define('models_restore', [ModelPolicy::class, 'restore']);
// categories Policy
Gate::define('categories_viewAny', [CategoryPolicy::class, 'viewAny']);
Gate::define('categories_viewAny_deleted', [CategoryPolicy::class, 'viewAny_deleted']);
Gate::define('categories_view', [CategoryPolicy::class, 'view']);
Gate::define('categories_create', [CategoryPolicy::class, 'create']);
Gate::define('categories_edit', [CategoryPolicy::class, 'edit']);
Gate::define('categories_delete', [CategoryPolicy::class, 'delete']);
Gate::define('categories_delete_force', [CategoryPolicy::class, 'delete_force']);
Gate::define('categories_restore', [CategoryPolicy::class, 'restore']);
// subcategories Policy
Gate::define('subcategories_viewAny', [SubcategoryPolicy::class, 'viewAny']);
Gate::define('subcategories_viewAny_deleted', [SubcategoryPolicy::class, 'viewAny_deleted']);
Gate::define('subcategories_view', [SubcategoryPolicy::class, 'view']);
Gate::define('subcategories_create', [SubcategoryPolicy::class, 'create']);
Gate::define('subcategories_edit', [SubcategoryPolicy::class, 'edit']);
Gate::define('subcategories_delete', [SubcategoryPolicy::class, 'delete']);
Gate::define('subcategories_delete_force', [SubcategoryPolicy::class, 'delete_force']);
Gate::define('subcategories_restore', [SubcategoryPolicy::class, 'restore']);
// products Policy
Gate::define('products_viewAny', [ProductPolicy::class, 'viewAny']);
Gate::define('products_viewAny_deleted', [ProductPolicy::class, 'viewAny_deleted']);
Gate::define('products_view', [ProductPolicy::class, 'view']);
Gate::define('products_create', [ProductPolicy::class, 'create']);
Gate::define('products_edit', [ProductPolicy::class, 'edit']);
Gate::define('products_delete', [ProductPolicy::class, 'delete']);
Gate::define('products_delete_force', [ProductPolicy::class, 'delete_force']);
Gate::define('products_restore', [ProductPolicy::class, 'restore']);
Gate::define('products_amount_add', [ProductPolicy::class, 'amount_add']);
Gate::define('products_amount_remove', [ProductPolicy::class, 'amount_remove']);
// cabel categories Policy
Gate::define('cabelCategories_viewAny',[CabelcategoryPolicy::class,'viewAny']);
Gate::define('cabelCategories_viewAny_deleted',[CabelcategoryPolicy::class,'viewAny_deleted']);
Gate::define('cabelCategories_view',[CabelcategoryPolicy::class,'view']);
Gate::define('cabelCategories_create',[CabelcategoryPolicy::class,'create']);
Gate::define('cabelCategories_edit',[CabelcategoryPolicy::class,'edit']);
Gate::define('cabelCategories_delete',[CabelcategoryPolicy::class,'delete']);
Gate::define('cabelCategories_delete_force',[CabelcategoryPolicy::class,'delete_force']);
Gate::define('cabelCategories_restore',[CabelcategoryPolicy::class,'restore']);
// cabels Policy
Gate::define('cabels_viewAny',[CabelPolicy::class,'viewAny']);
Gate::define('cabels_viewAny_deleted',[CabelPolicy::class,'viewAny_deleted']);
Gate::define('cabels_view',[CabelPolicy::class,'view']);
Gate::define('cabels_create',[CabelPolicy::class,'create']);
Gate::define('cabels_edit',[CabelPolicy::class,'edit']);
Gate::define('cabels_delete',[CabelPolicy::class,'delete']);
Gate::define('cabels_delete_force',[CabelPolicy::class,'delete_force']);
Gate::define('cabels_restore',[CabelPolicy::class,'restore']);
Gate::define('cabels_amount_add',[CabelPolicy::class,'amount_add']);
Gate::define('cabels_amount_remove',[CabelPolicy::class,'amount_remove']);
// loans Policy
Gate::define('loans_viewAny',[LoanPolicy::class,'viewAny']);
Gate::define('loans_create_user',[LoanPolicy::class,'create_user']);
Gate::define('loans_create_laptop',[LoanPolicy::class,'create_laptop']);
Gate::define('loans_adjust',[LoanPolicy::class,'adjust']);
Gate::define('loans_return',[LoanPolicy::class,'return']);
// reservations
Gate::define('reservations_viewAny',[ReservationPolicy::class,'viewAny']);
Gate::define('reservations_create',[ReservationPolicy::class,'create']);
Gate::define('reservations_validate',[ReservationPolicy::class,'validate']);
Gate::define('reservations_cancel',[ReservationPolicy::class,'cancel']);
Gate::define('reservations_setup',[ReservationPolicy::class,'setup']);
Gate::define('reservations_pickup',[ReservationPolicy::class,'pickup']);
Gate::define('reservations_extend',[ReservationPolicy::class,'extend']);
Gate::define('reservations_return',[ReservationPolicy::class,'return']);
// notes
Gate::define('notes_viewAny',[NotePolicy::class,'viewAny']);
Gate::define('notes_viewAny_deleted',[NotePolicy::class,'viewAny_deleted']);
Gate::define('notes_view',[NotePolicy::class,'view']);
Gate::define('notes_create',[NotePolicy::class,'create']);
Gate::define('notes_edit',[NotePolicy::class,'edit']);
Gate::define('notes_delete',[NotePolicy::class,'delete']);
Gate::define('notes_delete_force',[NotePolicy::class,'delete_force']);
Gate::define('notes_restore',[NotePolicy::class,'restore']);
// Other
Gate::define('home_page',[OtherPolicy::class,'home_page']);
Gate::define('logs_viewAny',[OtherPolicy::class,'logs']);
Gate::define('statistics',[OtherPolicy::class,'statistics']);
}
}