| 1: | <?php |
| 2: | |
| 3: | namespace Baril\Bonsai\Relations\Concerns; |
| 4: | |
| 5: | use Illuminate\Database\Eloquent\Model; |
| 6: | use LogicException; |
| 7: | |
| 8: | trait IsReadOnly |
| 9: | { |
| 10: | |
| 11: | |
| 12: | |
| 13: | protected function readOnly() |
| 14: | { |
| 15: | throw new LogicException("The $this->relationName relation is read-only!"); |
| 16: | } |
| 17: | |
| 18: | public function save(Model $model, array $pivotAttributes = [], $touch = true) |
| 19: | { |
| 20: | $this->readOnly(); |
| 21: | } |
| 22: | |
| 23: | public function saveMany($models, array $pivotAttributes = []) |
| 24: | { |
| 25: | $this->readOnly(); |
| 26: | } |
| 27: | |
| 28: | public function create(array $attributes = [], array $joining = [], $touch = true) |
| 29: | { |
| 30: | $this->readOnly(); |
| 31: | } |
| 32: | |
| 33: | public function createMany(iterable $records, array $joinings = []) |
| 34: | { |
| 35: | $this->readOnly(); |
| 36: | } |
| 37: | |
| 38: | public function toggle($ids, $touch = true) |
| 39: | { |
| 40: | $this->readOnly(); |
| 41: | } |
| 42: | |
| 43: | public function syncWithoutDetaching($ids) |
| 44: | { |
| 45: | $this->readOnly(); |
| 46: | } |
| 47: | |
| 48: | public function sync($ids, $detaching = true) |
| 49: | { |
| 50: | $this->readOnly(); |
| 51: | } |
| 52: | |
| 53: | public function attach($id, array $attributes = [], $touch = true) |
| 54: | { |
| 55: | $this->readOnly(); |
| 56: | } |
| 57: | |
| 58: | public function detach($ids = null, $touch = true) |
| 59: | { |
| 60: | $this->readOnly(); |
| 61: | } |
| 62: | } |
| 63: | |