public static function to($action) { return true; $model = ModelManager::getCurrent()->name; $modelPermissions = Artificer::modelManager()->getOption('action_permissions.' . $action, [], $model); return self::hasPermission($modelPermissions); }
/** * Relation constructor. * @param $name * @param null $value * @param array $options */ public function __construct($name, $value = null, $options = []) { parent::__construct($name, $value, $options); $this->modelManager = Artificer::modelManager(); $this->modelSettings = $this->modelManager->current(); $this->currentModel = $this->modelSettings->model; }
public function guessModel() { $method = $this->guessRelatedMethod(); $modelName = Str::studly($method); if ($method && Artificer::modelManager()->has($modelName)) { return $modelName; } }
public function __construct() { $this->theme = AdminOption::get('theme') . '::'; $this->masterLayout = 'base'; $this->modelManager = Artificer::modelManager(); if ($this->isStandAlone()) { $this->masterLayout = 'standalone'; $this->standalone = true; } $this->shareMainViewData(); }
public function input() { if (!$this->relation->getRelatedModel()) { throw new \Exception('missing relation in config for the current model.'); } $this->fields = array_get(\View::getShared(), 'fields'); $id = $this->fields['id']->value; $modelName = $this->relation->getRelatedModel(); $model = Artificer::modelManager()->get($modelName); $this->modelManager = $model; if ((Route::currentRouteName() == 'admin.model.create' || Route::currentRouteName() == 'admin.model.field') && Session::has('_set_relation_on_create_' . $this->modelSettings->name)) { $relateds = Session::get('_set_relation_on_create_' . $this->modelSettings->name); $related_ids = []; foreach ($relateds as $related) { $related_ids[] = $related['id']; } $data = $relateds[0]['modelClass']::whereIn('id', $related_ids)->get()->toArray(); } else { $data = $model['class']::where($this->relation->getForeignKey(), '=', $id)->get(['id', $this->relation->getShow()])->toArray(); } $this->showItems($data); $this->createRoute = $this->createRoute($this->modelManager['route']) . '?' . http_build_query([$this->relation->getForeignKey() => $id, '_standalone' => 'true']); if (!Request::ajax() || $this->showFullField) { $this->relationModal($this->modelManager['route'], $id); ?> <div class="text-right"> <div class="btn-group"> <button class="btn btn-default" data-toggle="modal" data-url="<?php echo $this->createRoute; ?> " data-target="#form-modal-<?php echo $this->modelManager['route']; ?> "> <i class="fa fa-plus"></i> </button> </div> </div> <?php } }
/** * Init the needed properties. */ protected function init() { $this->modelSettings = Artificer::modelManager()->current(); $this->currentModel = $this->modelSettings->model; }
public function isFillable() { $fillable = Artificer::modelManager()->current()->getFillable(); return $this->isAll($fillable) || in_array($this->getName(), $fillable); }