first version
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* 门店模型(小程序下单主体)
|
||||
*/
|
||||
class StoreModel extends Model
|
||||
{
|
||||
use SoftDeletes, HasFactory;
|
||||
|
||||
/** 状态:停用 */
|
||||
public const STATUS_DISABLED = 0;
|
||||
/** 状态:正常 */
|
||||
public const STATUS_NORMAL = 1;
|
||||
|
||||
protected $table = 'store';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'code',
|
||||
'level_id',
|
||||
'contact',
|
||||
'phone',
|
||||
'address',
|
||||
'payment_cycle_days',
|
||||
'status',
|
||||
'remark',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'level_id' => 'integer',
|
||||
'payment_cycle_days' => 'integer',
|
||||
'status' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* 所属客户等级(决定商品展示价格)
|
||||
*/
|
||||
public function level(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CustomerLevelModel::class, 'level_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店订单
|
||||
*/
|
||||
public function orders(): HasMany
|
||||
{
|
||||
return $this->hasMany(StoreOrderModel::class, 'store_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定本门店的小程序用户
|
||||
*/
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(UserModel::class, 'store_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店对账单
|
||||
*/
|
||||
public function statements(): HasMany
|
||||
{
|
||||
return $this->hasMany(StatementModel::class, 'store_id', 'id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user