| 1: | <?php |
| 2: | |
| 3: | namespace Baril\Orderly\Relations; |
| 4: | |
| 5: | use Illuminate\Database\Eloquent\Builder; |
| 6: | use Illuminate\Database\Eloquent\Model; |
| 7: | use Illuminate\Database\Eloquent\Relations\MorphToMany; |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | class MorphToManyOrderable extends MorphToMany |
| 13: | { |
| 14: | use Concerns\InteractsWithOrderablePivotTable { |
| 15: | newPivotQuery as _newPivotQuery; |
| 16: | } |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | public function __construct( |
| 34: | Builder $query, |
| 35: | Model $parent, |
| 36: | $name, |
| 37: | $orderColumn, |
| 38: | $table, |
| 39: | $foreignPivotKey, |
| 40: | $relatedPivotKey, |
| 41: | $parentKey, |
| 42: | $relatedKey, |
| 43: | $relationName = null, |
| 44: | $inverse = false |
| 45: | ) { |
| 46: | parent::__construct( |
| 47: | $query, |
| 48: | $parent, |
| 49: | $name, |
| 50: | $table, |
| 51: | $foreignPivotKey, |
| 52: | $relatedPivotKey, |
| 53: | $parentKey, |
| 54: | $relatedKey, |
| 55: | $relationName, |
| 56: | $inverse |
| 57: | ); |
| 58: | $this->setOrderColumn($orderColumn); |
| 59: | } |
| 60: | |
| 61: | |
| 62: | |
| 63: | |
| 64: | |
| 65: | |
| 66: | |
| 67: | public function newPivotQuery($ordered = true) |
| 68: | { |
| 69: | return $this->_newPivotQuery($ordered)->where($this->morphType, $this->morphClass); |
| 70: | } |
| 71: | } |
| 72: | |