| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Order extends Model
- {
- protected $pk = 'order_id';
- public function user()
- {
- return $this->belongsTo('User', 'user_id', 'user_id');
- }
- public function product()
- {
- return $this->belongsTo('Product', 'product_id', 'product_id');
- }
- public function getOrdList($condition, $fileds = '*', $limit = 10)
- {
- if (empty($condition)) {
- $result = $this
- ->field($fileds)
- ->order('order_id', 'desc')
- ->paginate($limit);
- } else {
- $result = $this
- ->where($condition)
- ->order('order_id', 'desc')
- ->paginate($limit);
- }
- return $result;
- }
- public function countOrder($condition)
- {
- $result = $this
- ->where($condition)
- ->count();
- return $result;
- }
- }
|