<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class OrderModel extends Model { protected $table = 'order'; protected $primaryKey = 'order_id'; public $timestamps = false; //已取消 -1 Cancelled //待审核 1 Waiting for approval //待付款 2 Waiting for payment //待付尾款 3 //待发货 4 Waiting for dispatch //部分发货 7 //待收货 8 Waiting for delivery //已完成 10 Transaction Complete const status_cancel = -1; const status_waiting_approval = 1; const status_waiting_pay =2 ; const status_waiting_end_pay =3 ; const status_waiting_send =4 ; const status_waiting_half_send =7 ; const status_waiting_delivery =8 ; const status_complete =10 ; static $status = [ self::status_cancel => "Cancelled", self::status_waiting_approval => "Waiting for approval", self::status_waiting_pay => "Waiting for payment", //self::status_waiting_end_pay => "", self::status_waiting_send => " Waiting for dispatch", // self::status_waiting_half_send => "", self::status_waiting_delivery => "Waiting for delivery", self::status_complete => "Transaction Complete", ]; public function order_items() { return $this->hasMany(OrderItemsModel::class, 'order_id', 'order_id'); } //获取订单详情 public static function getOrderInfo($where) { $res = self::where($where)->first(); return ($res) ? $res->toArray() : []; } }