12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Database\Query\Builder;
- class Goods extends Model {
- use SoftDeletes;
- protected $table = 'goods';
- protected $primaryKey = 'id';
- protected $dates = ['deleted_at'];
- function scopeType($query, $type) {
- return $query->whereType($type)->whereStatus(1)->orderByDesc('sort');
- }
- function getPriceAttribute($value) {
- return $value / 100;
- }
- function setPriceAttribute($value) {
- $this->attributes['price'] = $value * 100;
- }
- function getRenewAttribute($value) {
- return $value / 100;
- }
- function setRenewAttribute($value) {
- return $this->attributes['renew'] = $value * 100;
- }
- function getTrafficLabelAttribute() {
- return flowAutoShow($this->attributes['traffic'] * MB);
- }
- }
|