/** * @param $id */ public function setRowId($id, $column = 'id') { $this->entry = DB::table($this->entity->getTableName())->where($column, $id)->first(); foreach ($this->types as $field) { $field->setValue($this->entry->{$field->fieldSlug}); } }
/** * Handle the creation of the Field in the Database * @param $command * @return static */ public function handle($command) { $command->namespace = EntityModel::find($command->entity_id)->namespace; $field = FieldModel::create((array) $command); event(new FieldWasCreated($field)); return $field; }
public function create() { $entity = EntityModel::where('slug', 'tasks')->where('namespace', 'tasks')->firstOrFail(); $builder = new FormBuilder($entity); $builder->setReturnUrl(route('tasks.config.index')); JavaScript::put(['entity_id' => $entity->id]); return view('tasks::config.tasks.create')->with('form', $builder->render()); }
public function handle(FieldWasDeleted $event) { $field = $event->field; $entity = EntityModel::find($field['entity_id']); Schema::table($entity->getTableName(), function ($table) use($field) { $table->dropColumn($field['slug']); }); }
/** * Create a field for the user * @return $this */ public function createField() { $entity = EntityModel::where('slug', 'users')->firstOrFail(); $builder = new FormBuilder($entity); $builder->setReturnUrl(route('users.config')); JavaScript::put(['entity_id' => $entity->id]); return view('users::config.create')->with('form', $builder->render()); }
/** * Creates the Entity Record * @param $command * @return static */ public function handle($command) { $entity = EntityModel::create((array) $command); event(new EntityWasCreated($entity)); return $entity; }
public function getEntity() { return EntityModel::where('slug', 'boards')->where('namespace', 'tasks')->first(); }
/** * Execute the Middleware * @param object $command * @param callable $next * @return mixed */ public function execute($command, callable $next) { $command->entity = EntityModel::findOrFail($command->entity); return $next($command); }
/** * get the users entity for the form builder * @return mixed */ public function getEntity() { return EntityModel::where('slug', 'users')->where('namespace', 'app')->first(); }