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;
 }
Beispiel #3
0
 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']);
     });
 }
 /**
  * Creates the Entity Record
  * @param $command
  * @return static
  */
 public function handle($command)
 {
     $entity = EntityModel::create((array) $command);
     event(new EntityWasCreated($entity));
     return $entity;
 }
Beispiel #5
0
 /**
  * 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);
 }