创建版本
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php namespace Gdoo\Product\Models;
|
||||
|
||||
use DB;
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Product extends BaseModel
|
||||
{
|
||||
protected $table = 'product';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'product.index', 'url' => 'product/product/index', 'name' => '产品档案'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'enabled', 'name' => '启用'],
|
||||
['value' => 'disabled', 'name' => '禁用'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
|
||||
public function scopeType($query, $type = 1)
|
||||
{
|
||||
$types['sale'] = 1;
|
||||
$types['supplier'] = 2;
|
||||
return $query->LeftJoin('product_category', 'product_category.id', '=', 'product.category_id')
|
||||
->where('product_category.type', $types[$type]);
|
||||
}
|
||||
|
||||
public function warehouse($query)
|
||||
{
|
||||
return $this->belongsTo('Gdoo\Product\Models\Warehouse');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php namespace Gdoo\Product\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class ProductCategory extends BaseModel
|
||||
{
|
||||
protected $table = 'product_category';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'category.index', 'url' => 'product/category/index', 'name' => '产品类别'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
|
||||
public function scopeType($query, $type = 1)
|
||||
{
|
||||
$types['sale'] = 1;
|
||||
$types['supplier'] = 2;
|
||||
return $query->where('type', $types[$type]);
|
||||
}
|
||||
|
||||
public function products()
|
||||
{
|
||||
return $this->hasMany('Gdoo\Product\Models\Product', 'category_id');
|
||||
}
|
||||
|
||||
public function scopeDialog($q, $value)
|
||||
{
|
||||
return $q->whereIn('id', $value)->get()->toNested()->pluck('text', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php namespace Gdoo\Product\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class ProductUnit extends BaseModel
|
||||
{
|
||||
protected $table = 'product_unit';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'unit.index', 'url' => 'product/unit/index', 'name' => '计量单位'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'enabled', 'name' => '启用'],
|
||||
['value' => 'disabled', 'name' => '禁用'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user