31 lines
861 B
PHP
31 lines
861 B
PHP
<?php
|
|
|
|
namespace Modules\DocumentManagement\Policies;
|
|
|
|
use App\Models\User;
|
|
use Modules\DocumentManagement\Models\Document;
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
class DocumentPolicy
|
|
{
|
|
use HandlesAuthorization;
|
|
|
|
/**
|
|
* Determine whether the user can approve the document.
|
|
*/
|
|
public function approve(User $user, Document $document): bool
|
|
{
|
|
// Strict restriction: only users with 'Contractor Admin' user_type or specific roles
|
|
// Here we assume the Contractor Admin is denoted by a specific attribute or role.
|
|
return $user->user_type === 'Contractor Admin' || $user->hasRole('Contractor Admin');
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can upload a document.
|
|
*/
|
|
public function upload(User $user): bool
|
|
{
|
|
return true; // Customize based on exact permissions later
|
|
}
|
|
}
|