Good.php 639 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Good extends Model
  5. {
  6. public $appends = ['trace'];
  7. public static $templetOption = [
  8. [
  9. 'id' => 1,
  10. 'name' => '绿豆模板',
  11. 'value' => 'key'
  12. ],
  13. [
  14. 'id' => 2,
  15. 'name' => '玉米模板',
  16. 'value' => 'yumi'
  17. ],
  18. [
  19. 'id' => 3,
  20. 'name' => '经销商模板',
  21. 'value' => 'jingxiaoshang'
  22. ]
  23. ];
  24. public function getTraceAttribute()
  25. {
  26. return Trace::where('gid', $this->attributes['id'])->count();
  27. }
  28. }