You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
699 B

  1. <?php
  2. namespace App;
  3. use Movim\Model;
  4. class Identity extends Model
  5. {
  6. public $primaryKey = ['info_id', 'category', 'type'];
  7. public $incrementing = false;
  8. public function info()
  9. {
  10. return $this->belongsTo('App\Info');
  11. }
  12. public static function saveMany($identities)
  13. {
  14. if ($identities->isNotEmpty()) {
  15. Identity::upsert($identities->map(function (Identity $identity) {
  16. return [
  17. 'info_id' => $identity->info_id,
  18. 'category' => $identity->category,
  19. 'type' => $identity->type,
  20. ];
  21. })->all(), $identities->first()->primaryKey);
  22. }
  23. }
  24. }