Beispiel #1
0
 /**
  * Create a new has one or many relationship instance for CMS special relations.
  *
  * @param \Illuminate\Database\Eloquent\Builder $query
  * @param \Illuminate\Database\Eloquent\Model   $parent
  * @param string                                $foreignKey
  * @param string                                $localKey
  * @param int|null                              $fieldId
  * @param int                                   $type
  */
 public function __construct(Builder $query, Model $parent, $foreignKey, $localKey, $fieldId = null, $type = CmsModel::RELATION_TYPE_IMAGE)
 {
     $this->fieldId = $fieldId;
     switch ($type) {
         case CmsModel::RELATION_TYPE_CHECKBOX:
             $this->fieldKey = config('pxlcms.relations.checkboxes.keys.field', 'field_id');
             break;
         case CmsModel::RELATION_TYPE_FILE:
             $this->fieldKey = config('pxlcms.relations.files.keys.field', 'field_id');
             break;
         case CmsModel::RELATION_TYPE_IMAGE:
         default:
             $this->fieldKey = config('pxlcms.relations.images.keys.field', 'from_field_id');
     }
     parent::__construct($query, $parent, $foreignKey, $localKey);
 }
Beispiel #2
0
 /**
  * Create a new has many relationship instance.
  * @return void
  */
 public function __construct(Builder $query, Model $parent, $foreignKey, $localKey, $relationName = null)
 {
     $this->relationName = $relationName;
     parent::__construct($query, $parent, $foreignKey, $localKey);
 }