我正在使用 Compoships 包使 Laravel 支持多键关系,但我想覆盖这个包中的特征函数。
这是当前的流程:
我在我的项目中使用的主要特征使用了包中的另一个,它使用了另一个(我想要覆盖的那个)
public function addConstraints()
{
if (static::$constraints) {
$foreignKey = $this->getForeignKeyName();
$parentKeyValue = $this->getParentKey();
//If the foreign key is an array (multi-column relationship), we adjust the query.
if (is_array($this->foreignKey)) {
foreach ($this->foreignKey as $index => $key) {
/*list(, $key) = explode('.', $key);
$fullKey = $this->getRelated()->getTable().'.'.$key;*/
$keyPortions = explode('.', $key);
if(count($keyPortions) === 2)
$fullKey = $this->getRelated()->getTable() . '.' . $key;
else
$fullKey = $key;
$this->query->where($fullKey, '=', $parentKeyValue[$index]);
$this->query->whereNotNull($fullKey);
}
} else {
$fullKey = $this->getRelated()->getTable().'.'.$foreignKey;
$this->query->where($fullKey, '=', $parentKeyValue);
$this->query->whereNotNull($fullKey);
}
}
}
我能够在本地覆盖它,但是一旦我部署代码(发生作曲家更新),我就会丢失我的修改
所以我该怎么做?