链街Dcat后台
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.

39 lines
1.0 KiB

5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\Model;
  5. class ImsCjdcOrder extends Model
  6. {
  7. use HasDateTimeFormatter;
  8. protected $table = 'lanzu_order as order';
  9. public $timestamps = false;
  10. public function user()
  11. {
  12. return $this->hasOne('\App\Models\ImsCjdcUser','id','user_id');
  13. }
  14. public function store()
  15. {
  16. return $this->hasOne('\App\Models\LanzuStore','id','store_id');
  17. }
  18. public static function getOrdersData($oid)
  19. {
  20. $orders = ImsCjdcOrder::with('user')->with('store')
  21. ->where('order_main_id', $oid)->get()->toArray();
  22. if (count($orders)) {
  23. foreach ($orders as &$or) {
  24. if (substr($or['store']['logo'], 0, 4) != 'http') {
  25. $or['store']['logo'] = env('IMG_HOST') . '/' . $or['store']['logo'];
  26. }
  27. $or['goods'] = LanzuOrderGoods::where('order_id', $or['id'])->get()->toArray();
  28. }
  29. }
  30. return json_encode($orders);
  31. }
  32. }