2025-04-28 16:15:09 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
2025-05-05 09:44:50 +08:00
|
|
|
use App\BaseApp\BaseModel;
|
2025-04-28 16:45:23 +08:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
2025-04-28 16:15:09 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 订单表
|
|
|
|
|
*/
|
2025-05-05 09:44:50 +08:00
|
|
|
class OrderModel extends BaseModel
|
2025-04-28 16:15:09 +08:00
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
protected $table = 'orders';
|
|
|
|
|
|
|
|
|
|
protected $guarded = [];
|
2025-04-28 16:45:23 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户关联
|
|
|
|
|
* @return HasOne
|
|
|
|
|
*/
|
|
|
|
|
public function user()
|
|
|
|
|
{
|
2025-05-05 09:44:50 +08:00
|
|
|
return $this->hasOne(UserModel::class, 'id', 'user_id');
|
2025-04-28 16:45:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 订单详情
|
|
|
|
|
* @return HasMany
|
|
|
|
|
*/
|
|
|
|
|
public function items(): HasMany
|
|
|
|
|
{
|
2025-05-05 09:44:50 +08:00
|
|
|
return $this->hasMany(OrderItemModel::class, 'order_id', 'id');
|
2025-04-28 16:45:23 +08:00
|
|
|
}
|
2025-04-28 16:15:09 +08:00
|
|
|
}
|