<?php

namespace App\Models;

use App\Models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * @description 产品规格
 * @author  system;
 * @version    1.0
 * @date 2018-07-12 08:29:26
 *
 */
class ProductInfoModel extends BaseModel
{
    use SoftDeletes;
    /**
     * 数据表名
     *
     * @var string
     *
     */
    protected $table = 'product_info';
    /**
     * 主键
     */
    protected $primaryKey = 'id';

    //分页
    protected $perPage = PAGE_NUMS;

    /**
     * 可以被集体附值的表的字段
     *
     * @var string
     */
    protected $fillable = [
        'name',
        'category_id',
        'origin_price',
        'current_price',
        'deposit',
        'service_time'
    ];

    public function catename(){
        return (new ProductCategoryModel())->find($this->category_id)?(new ProductCategoryModel())->find($this->category_id)->name:$this->category_id;
    }

}