mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
20 lines
533 B
PHP
20 lines
533 B
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
class DocumentPolicy extends EntityPolicy {
|
|
public static function create($user){
|
|
return !empty($user);
|
|
}
|
|
|
|
public static function view($user, $document) {
|
|
if($user->hasPermission('view_all'))return true;
|
|
if($document->expense){
|
|
if($document->expense->invoice)return $user->can('view', $document->expense->invoice);
|
|
return $user->can('view', $document->expense);
|
|
}
|
|
if($document->invoice)return $user->can('view', $document->invoice);
|
|
|
|
return $user->owns($item);
|
|
}
|
|
} |