master
parent
7f2c6a9869
commit
3626667aeb
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Peidikeji\Goods\Filters;
|
||||||
|
|
||||||
|
use EloquentFilter\ModelFilter;
|
||||||
|
|
||||||
|
class GoodsFilter extends ModelFilter
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -2,12 +2,15 @@
|
||||||
|
|
||||||
namespace Peidikeji\Goods\Models;
|
namespace Peidikeji\Goods\Models;
|
||||||
|
|
||||||
|
use EloquentFilter\Filterable;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Peidikeji\Goods\Filters\GoodsFilter;
|
||||||
|
|
||||||
class Goods extends Model
|
class Goods extends Model
|
||||||
{
|
{
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
use Filterable;
|
||||||
|
|
||||||
protected $table = 'goods';
|
protected $table = 'goods';
|
||||||
|
|
||||||
|
|
@ -21,6 +24,11 @@ class Goods extends Model
|
||||||
'images' => 'array',
|
'images' => 'array',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function modelFilter()
|
||||||
|
{
|
||||||
|
return GoodsFilter::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function category()
|
public function category()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(GoodsCategory::class, 'category_id');
|
return $this->belongsTo(GoodsCategory::class, 'category_id');
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ class CreateGoodsTable extends Migration
|
||||||
Schema::create('goods', function (Blueprint $table) {
|
Schema::create('goods', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->unsignedBigInteger('category_id')->comment('所属分类, 关联 goods_category.id');
|
$table->unsignedBigInteger('category_id')->comment('所属分类, 关联 goods_category.id');
|
||||||
|
$table->unsignedBigInteger('merchant_id')->nullable()->comment('商户ID');
|
||||||
$table->unsignedBigInteger('type_id')->nullable()->comment('所属类别');
|
$table->unsignedBigInteger('type_id')->nullable()->comment('所属类别');
|
||||||
$table->unsignedBigInteger('brand_id')->nullable()->comment('所属品牌');
|
$table->unsignedBigInteger('brand_id')->nullable()->comment('所属品牌');
|
||||||
$table->string('name')->comment('商品名称');
|
$table->string('name')->comment('商品名称');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue