50 lines
1.1 KiB
PHP
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');
|
|
}
|
|
}
|