Files
nl-mall-api/app/Models/ProductModel.php

50 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2025-05-19 16:54:25 +08:00
<?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');
}
2025-05-19 16:54:25 +08:00
}