| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- // +----------------------------------------------------------------------
- // | likeadmin快速开发前后端分离管理后台(PHP版)
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | 开源版本可自由商用,可去除界面版权logo
- // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
- // | github下载:https://github.com/likeshop-github/likeadmin
- // | 访问官网:https://www.likeadmin.cn
- // | likeadmin团队 版权所有 拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeadminTeam
- // +----------------------------------------------------------------------
- namespace app\common\model\goods;
- use app\common\model\BaseModel;
- use app\common\model\goods_category\GoodsCategory;
- use app\common\model\performance\PerformanceRules;
- /**
- * Goods模型
- * Class GoodsEnum
- * @package app\common\model\goods
- */
- class Goods extends BaseModel
- {
-
- protected $name = 'goods';
- protected $type = [
- 'goods_category_ids' => 'array',
- 'goods_banners' => 'array'
- ];
- public function goodsCategory()
- {
- return $this->hasOne(GoodsCategory::class, 'id', 'goods_category_id')
- ->field('id,name,picture');
- }
- public function performanceRules()
- {
- return $this->hasOne(PerformanceRules::class, 'goods_id', 'id')
- ->field('goods_id,type,rate');
- }
- public function getIsTypeAttr($value,$data)
- {
- if ($data['is_agent'] == 1 && $data['is_activity'] == 1) {
- return -1;
- } else if ($data['is_agent'] == 1 && $data['is_activity'] == 0) {
- return 1;
- } else if ($data['is_agent'] == 0 && $data['is_activity'] == 1) {
- return 2;
- } else {
- return 0;
- }
- }
- public function getLabelsAttr($value)
- {
- return $value?array_map(function($item){ return (int)$item; },explode(',',$value)):[];
- }
- }
|