DispatchWidget.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 03/03/2017
  6. * Time: 12:19
  7. */
  8. namespace app\backend\widgets\goods;
  9. use app\common\components\Widget;
  10. use app\backend\modules\goods\models\GoodsDispatch;
  11. use app\backend\modules\goods\models\Dispatch;
  12. use app\common\models\DispatchType;
  13. class DispatchWidget extends Widget
  14. {
  15. public function run()
  16. {
  17. if ($this->goods_id && GoodsDispatch::getInfo($this->goods_id)) {
  18. $dispatch = GoodsDispatch::getInfo($this->goods_id);
  19. } else {
  20. $dispatch = new Goodsdispatch();
  21. }
  22. $dispatch_templates = Dispatch::getAll();
  23. // edit 2018-06-01 by Yy
  24. if ($dispatch->dispatch_id) {
  25. $verify_dispatch = Dispatch::find($dispatch->dispatch_id);
  26. if ($verify_dispatch->is_plugin == 1) {
  27. $dispatch_templates = [
  28. $verify_dispatch
  29. ];
  30. }
  31. }
  32. $dispatch['dispatchTypesSetting'] = $dispatch->dispatchTypesSettingV2();
  33. return view('goods.widgets.dispatch', [
  34. 'dispatch' => $dispatch,
  35. 'dispatch_templates' => $dispatch_templates,
  36. ])->render();
  37. }
  38. }