Goods.php 521 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Http\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * 商品
  6. * Class Goods
  7. *
  8. * @package App\Http\Models
  9. */
  10. class Goods extends Model
  11. {
  12. protected $table = 'goods';
  13. protected $primaryKey = 'id';
  14. function label()
  15. {
  16. return $this->hasMany(GoodsLabel::class, 'goods_id', 'id');
  17. }
  18. function getPriceAttribute($value)
  19. {
  20. return $value / 100;
  21. }
  22. function setPriceAttribute($value)
  23. {
  24. $this->attributes['price'] = $value * 100;
  25. }
  26. }