1
0
Files
lkafu/app/Models/GoodsParams.php
2020-08-06 14:45:56 +08:00

73 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\SoftDeletes;
use RuLong\Order\Contracts\Orderable;
class GoodsParams extends Model implements Orderable
{
use SoftDeletes;
public function goods()
{
return $this->belongsTo(Goods::class, 'goods_id', 'id');
}
public function getTitle()
{
return $this->goods ? $this->goods->title . '-' . $this->value : '';
}
public function getPrice()
{
return $this->price;
}
public function getParticipate()
{
return $this->participate;
}
public function getScore()
{
return $this->score;
}
public function getStock()
{
return $this->stock;
}
public function getSellerPrice()
{
return $this->cost;
}
public function deductStock($stock)
{
$this->decrement('stock', $stock);
}
public function addStock($stock)
{
$this->increment('stock', $stock);
}
public function addSold($sold)
{
$this->goods()->increment('sold', $sold);
}
protected function getStorageAttribute()
{
return $this->goods ? $this->goods->cover_path : '';
}
public function getFreight($address, $number)
{
return 0;
}
}