feat: 产品
refactor: 产品详情页seo
This commit is contained in:
15
app/index/model/ProductAttrModel.php
Normal file
15
app/index/model/ProductAttrModel.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use app\common\model\ProductAttrBaseModel;
|
||||
|
||||
/**
|
||||
* 产品属性模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ProductAttrModel extends ProductAttrBaseModel
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -28,4 +28,21 @@ class ProductCategoryModel extends ProductCategoryBaseModel
|
||||
{
|
||||
$query->where('is_show', '=', 1);
|
||||
}
|
||||
|
||||
// 所属所有子分类范围查询
|
||||
public function scopeChild($query, $id, $merge_self = false)
|
||||
{
|
||||
$query->where(function($q) use($id, $merge_self) {
|
||||
$q->where('pid', '=', $id);
|
||||
if ($merge_self) {
|
||||
$q->whereOr('id', '=', $id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 所属所有子孙分类范围查询
|
||||
public function scopeChildren($query, $id)
|
||||
{
|
||||
$query->whereRaw('FIND_IN_SET(:id, path)', ['id' => $id]);
|
||||
}
|
||||
}
|
||||
|
||||
15
app/index/model/ProductInquiryModel.php
Normal file
15
app/index/model/ProductInquiryModel.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use app\common\model\ProductInquiryBaseModel;
|
||||
|
||||
/**
|
||||
* 产品询盘表模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ProductInquiryModel extends ProductInquiryBaseModel
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -17,6 +17,28 @@ class ProductModel extends ProductBaseModel
|
||||
// 软件删除时间字段
|
||||
protected $deleteTime = 'deleted_at';
|
||||
|
||||
// 关联产品分类
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(ProductCategoryModel::class, 'category_id', 'id');
|
||||
}
|
||||
|
||||
// 关联sku
|
||||
public function sku()
|
||||
{
|
||||
return $this->hasMany(ProductSkuModel::class, 'product_id', 'id');
|
||||
}
|
||||
|
||||
// 所属分类范围查询
|
||||
public function scopeByCategory($query, $category)
|
||||
{
|
||||
if (is_array($category)) {
|
||||
$query->whereIn('category_id', $category);
|
||||
return;
|
||||
}
|
||||
$query->where('category_id', '=', $category);
|
||||
}
|
||||
|
||||
// 所属语言范围查询
|
||||
public function scopeLanguage($query, $language)
|
||||
{
|
||||
|
||||
23
app/index/model/ProductParamsModel.php
Normal file
23
app/index/model/ProductParamsModel.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use app\common\model\ProductParamsBaseModel;
|
||||
|
||||
/**
|
||||
* 产品参数模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ProductParamsModel extends ProductParamsBaseModel
|
||||
{
|
||||
// 所属产品范围查询
|
||||
public function scopeByProductId($query, $product)
|
||||
{
|
||||
if (is_array($product)) {
|
||||
$query->whereIn('product_id', $product);
|
||||
return;
|
||||
}
|
||||
$query->where('product_id', '=', $product);
|
||||
}
|
||||
}
|
||||
28
app/index/model/ProductPurchaseLinkModel.php
Normal file
28
app/index/model/ProductPurchaseLinkModel.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use app\common\model\ProductPurchaseLinkBaseModel;
|
||||
|
||||
/**
|
||||
* 产品购买链接模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ProductPurchaseLinkModel extends ProductPurchaseLinkBaseModel
|
||||
{
|
||||
// 关联购买平台
|
||||
public function platform()
|
||||
{
|
||||
return $this->hasOne(ProductPurchasePlatformModel::class, 'id', 'platform_id');
|
||||
}
|
||||
|
||||
// 所属产品范围查询
|
||||
public function scopeByProductId($query, $product_id)
|
||||
{
|
||||
if (is_array($product_id)) {
|
||||
return $query->where('product_id', 'IN', $product_id);
|
||||
}
|
||||
return $query->where('product_id', '=', $product_id);
|
||||
}
|
||||
}
|
||||
15
app/index/model/ProductPurchasePlatformModel.php
Normal file
15
app/index/model/ProductPurchasePlatformModel.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use app\common\model\ProductPurchasePlatformBaseModel;
|
||||
|
||||
/**
|
||||
* 产品购买平台模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ProductPurchasePlatformModel extends ProductPurchasePlatformBaseModel
|
||||
{
|
||||
//
|
||||
}
|
||||
25
app/index/model/ProductRelatedModel.php
Normal file
25
app/index/model/ProductRelatedModel.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use app\common\model\ProductRelatedBaseModel;
|
||||
|
||||
/**
|
||||
* 相关产品表模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ProductRelatedModel extends ProductRelatedBaseModel
|
||||
{
|
||||
// 关联产品
|
||||
public function product()
|
||||
{
|
||||
return $this->hasOne(ProductModel::class, 'id', 'related_product_id');
|
||||
}
|
||||
|
||||
// 所属产品范围查询
|
||||
public function scopeByProductId($builder, $product_id)
|
||||
{
|
||||
return $builder->where('product_id', '=', $product_id);
|
||||
}
|
||||
}
|
||||
19
app/index/model/ProductSkuAttrModel.php
Normal file
19
app/index/model/ProductSkuAttrModel.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use app\common\model\ProductSkuAttrBaseModel;
|
||||
|
||||
/**
|
||||
* 产品SKU属性模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ProductSkuAttrModel extends ProductSkuAttrBaseModel
|
||||
{
|
||||
// 所属sku范围查询
|
||||
public function scopeBySkuId($query, $sku_ids)
|
||||
{
|
||||
return $query->where('sku_id', 'IN', $sku_ids);
|
||||
}
|
||||
}
|
||||
33
app/index/model/ProductSkuModel.php
Normal file
33
app/index/model/ProductSkuModel.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use app\common\model\ProductSkuBaseModel;
|
||||
|
||||
/**
|
||||
* 产品SKU模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ProductSkuModel extends ProductSkuBaseModel
|
||||
{
|
||||
// json字段
|
||||
protected $json = ['photo_album'];
|
||||
protected $jsonAssoc = true;
|
||||
|
||||
// 关联sku属性
|
||||
public function attr()
|
||||
{
|
||||
return $this->hasMany(ProductSkuAttrModel::class, 'sku_id', 'id');
|
||||
}
|
||||
|
||||
// 所属产品范围查询
|
||||
public function scopeByProductId($query, $product)
|
||||
{
|
||||
if (is_array($product)) {
|
||||
$query->whereIn('product_id', $product);
|
||||
return;
|
||||
}
|
||||
$query->where('product_id', '=', $product);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user