<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

// 活动表
class Cut extends Model {
	protected $table = 'cut';
	protected $fillable = [ 
			'user_id',
			'goods_id',
			'status',
			'final_price',
			'current_price'
	];
	const TYPE_START = 1;
	const TYPE_HELP = 2;
	const STATUS_ING = 1;
	const STATUS_SUCCESS = 2;
	const STATUS_fAIL = 3;
	public static $statusArr = [ 
			self::STATUS_ING => '进行中',
			self::STATUS_SUCCESS => '成功',
			self::STATUS_fAIL => '失败'
	];
	public static function isSelfCut($cutId, $userId) {
		$cut = self::find ( $cutId );
		return $cut->user_id = $userId;
	}
	public function cutLogs() {
		return $this->hasMany ( CutLog::class, 'cut_id', 'id' );
	}

	public function goods(){
	    return $this->belongsTo(Goods::class);
    }
}
