Dealer.php 546 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Dealer extends Model
  5. {
  6. protected $guarded = [];
  7. public function import($data, $info)
  8. {
  9. foreach ($data as $v) {
  10. if (!self::where('identifier', $v['identifier'])->count()) {
  11. self::firstOrCreate($v);
  12. }
  13. }
  14. return true;
  15. }
  16. public static function getOption()
  17. {
  18. $data = self::where('status', 1)->pluck('name', 'id')->toArray();
  19. return array_prepend($data, '暂无', 0);
  20. }
  21. }