Car-Repairs-Shop/app/Providers/AuthServiceProvider.php
sackey 5403c3591d
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
feat: Enhance job card workflow with diagnosis actions and technician assignment modal
- Added buttons for assigning diagnosis and starting diagnosis based on job card status in the job card view.
- Implemented a modal for assigning technicians for diagnosis, including form validation and technician selection.
- Updated routes to include a test route for job cards.
- Created a new Blade view for testing inspection inputs.
- Developed comprehensive feature tests for the estimate module, including creation, viewing, editing, and validation of estimates.
- Added tests for estimate model relationships and statistics calculations.
- Introduced a basic feature test for job cards index.
2025-08-15 08:37:45 +00:00

77 lines
2.3 KiB
PHP

<?php
namespace App\Providers;
use App\Models\Estimate;
use App\Models\JobCard;
use App\Models\User;
use App\Policies\EstimatePolicy;
use App\Policies\JobCardPolicy;
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 = [
JobCard::class => JobCardPolicy::class,
Estimate::class => EstimatePolicy::class,
];
/**
* Register any authentication / authorization services.
*/
public function boot(): void
{
$this->registerPolicies();
// Define gates for common permission checks
Gate::define('access-admin-panel', function (User $user) {
return $user->hasAnyRole(['admin', 'manager'], $user->branch_code);
});
Gate::define('manage-users', function (User $user) {
return $user->hasPermission('users.create', $user->branch_code) ||
$user->hasPermission('users.update', $user->branch_code) ||
$user->hasPermission('users.delete', $user->branch_code);
});
Gate::define('view-reports', function (User $user) {
return $user->hasAnyPermission([
'reports.view',
'reports.financial',
'reports.operational',
], $user->branch_code);
});
Gate::define('manage-inventory', function (User $user) {
return $user->hasAnyPermission([
'inventory.create',
'inventory.update',
'inventory.delete',
'inventory.stock-movements',
'inventory.purchase-orders',
], $user->branch_code);
});
Gate::define('supervise-service', function (User $user) {
return $user->hasAnyRole([
'service_supervisor',
'service_coordinator',
'manager',
], $user->branch_code);
});
// Super admin gate (bypass all restrictions)
Gate::before(function (User $user, string $ability) {
if ($user->hasRole('admin')) {
return true;
}
});
}
}