Exchange.php 533 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace App\Models;
  3. use App\Models\Relations\BelongsToUserTrait;
  4. use Illuminate\Database\Eloquent\Model;
  5. class Exchange extends Model
  6. {
  7. use BelongsToUserTrait;
  8. protected $table = 'exchanges';
  9. protected $fillable = ['user_id','coins', 'goods_id','real_name','phone','email','comment','status'];
  10. static function newest()
  11. {
  12. return self::orderBy('created_at','desc')->take(10)->get();
  13. }
  14. public function goods(){
  15. return $this->belongsTo('App\Models\Goods','goods_id');
  16. }
  17. }