AttributeProduct.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Packages\Product\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. class AttributeProduct extends Model
  6. {
  7. use SoftDeletes;
  8. protected $table = 'attribute_products';
  9. protected $guarded = [];
  10. public static function sync_attr(array $attributes = [])
  11. {
  12. $model = new static($attributes);
  13. $model->save();
  14. return $model;
  15. }
  16. // public function sync_attr($ids, $detaching = true)
  17. // {
  18. // $changes = [
  19. // 'attached' => [], 'detached' => [], 'updated' => [],
  20. // ];
  21. // $current = $this->getCurrentlyAttachedPivots()
  22. // ->pluck($this->relatedPivotKey)->all();
  23. // $detach = array_diff($current, array_keys(
  24. // $records = $this->formatRecordsList($this->parseIds($ids))
  25. // ));
  26. // if ($detaching && count($detach) > 0) {
  27. // $this->detach($detach);
  28. //
  29. // $changes['detached'] = $this->castKeys($detach);
  30. // }
  31. // $changes = array_merge(
  32. // $changes, $this->attachNew($records, $current, false)
  33. // );
  34. // if (count($changes['attached']) ||
  35. // count($changes['updated'])) {
  36. // $this->touchIfTouching();
  37. // }
  38. // return $changes;
  39. // }
  40. }