namespace Cubist\Backpack\app;
+use Backpack\CRUD\app\Exceptions\AccessDeniedException;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanel;
use Cubist\Backpack\app\Magic\Models\CubistMagicAbstractModel;
+use Illuminate\Support\Facades\Gate;
/**
* @property CubistMagicAbstractModel $model
$this->_seenFieldTypes[$type] = true;
return true;
}
+
+ public function hasAccess($operation)
+ {
+ // First filter with standard backpack gate
+ if (!parent::hasAccess($operation)) {
+ return false;
+ }
+
+
+ return true;
+ }
+
+ public function hasAccessOrFail($operation)
+ {
+ if (!$this->hasAccess($operation)) {
+ throw new AccessDeniedException(trans('backpack::crud.unauthorized_access', ['access' => $operation]));
+ }
+
+ return true;
+ }
+
+ public function hasAccessToAll($operation_array)
+ {
+ foreach ((array)$operation_array as $key => $operation) {
+ if (!$this->hasAccess($operation)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public function hasAccessToAny($operation_array)
+ {
+ foreach ((array)$operation_array as $key => $operation) {
+ if ($this->hasAccess($operation) == true) {
+ return true;
+ }
+ }
+
+ return false;
+ }
}