ExpressCompany.php 871 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2018/7/30
  6. * Time: 上午10:42
  7. */
  8. namespace app\common\repositories;
  9. use Illuminate\Database\Eloquent\Collection;
  10. use Yunshop\ExpressCompany\Common\Models\ExpressCompanyModel;
  11. class ExpressCompany extends Collection
  12. {
  13. static public function create()
  14. {
  15. $file = implode([app()->path(), '..', 'static', 'source', 'expresscom.json'], DIRECTORY_SEPARATOR);
  16. $json = file_get_contents($file);
  17. $items = json_decode($json, true);
  18. $items = array_filter($items,function ($v) {
  19. return $v['name'];
  20. });
  21. if (app('plugins')->isEnabled('express-company')) {
  22. $data = ExpressCompanyModel::uniacid()->select('name','value')->get()->toArray();
  23. $items = array_merge($data,$items);
  24. }
  25. return new static($items);
  26. }
  27. }