35 lines
872 B
PHP
35 lines
872 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
|
|
{
|
|
if ($user->hasRole('Super Admin') || $user->hasRole('admin') || $user->user_type === 'admin') {
|
|
return true;
|
|
}
|
|
|
|
return $user->hasRole('Main Contractor Admin')
|
|
|| $user->can('documents.approve')
|
|
|| $user->can('approve documents');
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can upload a document.
|
|
*/
|
|
public function upload(User $user): bool
|
|
{
|
|
return true; // Customize based on exact permissions later
|
|
}
|
|
}
|