Пример #1
0
 /**
  * FieldBlueprint constructor.
  * @param $name string
  * @param $type string field type
  * @param $args
  * @param ModelBlueprint|null $parent
  */
 public function __construct($name, $type, $args, ModelBlueprint $parent = null)
 {
     if (empty(static::$fieldSetup)) {
         static::boot();
     }
     $this->name = $name;
     $this->type = $type;
     $this->args = $args;
     if ($parent) {
         $this->blueprint = $parent;
         // The descriptions are located in localization files.
         // tableName.columnName => description with {plural} labels
         $this->description = trans("{$parent->table()}.{$name}", $parent->labels()->toArray());
     }
 }
Пример #2
0
 /**
  * Modify protected attributes at runtime.
  * This is a way to override a models defaults on a client by client basis.
  * @param ModelBlueprint $blueprint|null
  * @return void
  */
 protected function configureModel(ModelBlueprint $blueprint = null)
 {
     if (empty($blueprint)) {
         return null;
     }
     $this->blueprint = $blueprint;
     $this->table = $blueprint->table();
     $this->appends = array_merge($this->appends, ['objectUrl', 'objectEditUrl', 'objectTitle']);
     if (!$this instanceof Media) {
         $this->appends[] = "objectImage";
     }
     foreach (['fillable', ' guarded', 'hidden', 'dates', 'searchable'] as $property) {
         if ($blueprint->{$property}()) {
             $this->{$property} = array_merge($this->{$property}, $blueprint->{$property}()->keys()->toArray());
         }
     }
     $this->timestamps = $blueprint->timestamps;
 }