Files
nl-mall-api/app/Models/ProductModel.php
lq 035ab1105c
Some checks failed
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
商品、订单部分相关代码生成,下一步先把商品搞完再搞订单
2025-05-20 16:52:47 +08:00

50 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use App\BaseApp\BaseModel;
use Illuminate\Database\Eloquent\Relations\HasMany;
class ProductModel extends BaseModel
{
protected $table = 'product';
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $guarded = [];
public function images(): HasMany
{
return $this->hasMany(ProductImageModel::class, 'product_id', 'id');
}
public function mall()
{
return $this->hasOne(MallModel::class, 'id', 'mall_id');
}
public function user()
{
return $this->hasOne(AdminModel::class, 'id', 'user_id');
}
public function labels()
{
// return $this->hasMany(ProductLabelRelationsModel::class, 'product_id', 'id');
return $this->belongsToMany(ProductLabelModel::class, 'product_label_relations', 'product_id', 'label_id');
}
public function classification()
{
return $this->hasOne(ProductClassificationModel::class, 'id', 'classification_id');
}
public function skus()
{
return $this->hasMany(SkuModel::class, 'product_id', 'id');
}
}