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.

31 lines
793 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(Info::class);
  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. 'lang' => $identity->lang,
  21. 'name' => $identity->name
  22. ];
  23. })->all(), $identities->first()->primaryKey);
  24. }
  25. }
  26. }