Good.php 751 B

12345678910111213141516171819202122232425262728293031323334353637
  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. 'id' => 4,
  25. 'name' => '禾美乐',
  26. 'value' => 'hemeile'
  27. ]
  28. ];
  29. public function getTraceAttribute()
  30. {
  31. return Trace::where('gid', $this->attributes['id'])->count();
  32. }
  33. }