12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace Packages\Product\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\SoftDeletes;
- class AttributeProduct extends Model
- {
- use SoftDeletes;
- protected $table = 'attribute_products';
- protected $guarded = [];
- public static function sync_attr(array $attributes = [])
- {
- $model = new static($attributes);
- $model->save();
- return $model;
- }
- // public function sync_attr($ids, $detaching = true)
- // {
- // $changes = [
- // 'attached' => [], 'detached' => [], 'updated' => [],
- // ];
- // $current = $this->getCurrentlyAttachedPivots()
- // ->pluck($this->relatedPivotKey)->all();
- // $detach = array_diff($current, array_keys(
- // $records = $this->formatRecordsList($this->parseIds($ids))
- // ));
- // if ($detaching && count($detach) > 0) {
- // $this->detach($detach);
- //
- // $changes['detached'] = $this->castKeys($detach);
- // }
- // $changes = array_merge(
- // $changes, $this->attachNew($records, $current, false)
- // );
- // if (count($changes['attached']) ||
- // count($changes['updated'])) {
- // $this->touchIfTouching();
- // }
- // return $changes;
- // }
- }
|