链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1005 B

  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Laravel\Scout\Searchable;
  5. use Illuminate\Support\Str;
  6. class LanzuGoods extends Model
  7. {
  8. use Searchable;
  9. protected $table = 'lanzu_goods';
  10. protected $dateFormat = 'U';
  11. public function getCoverImgAttribute($v){
  12. if(Str::startsWith($v,"http")){
  13. return $v;
  14. }else{
  15. return env('IMG_HOST') . $v;
  16. }
  17. }
  18. public function searchableAs()
  19. {
  20. return 'lanzu-goods-test';
  21. }
  22. public function toSearchableArray()
  23. {
  24. return [
  25. 'name' => $this->name,
  26. 'market_id' => $this->market_id,
  27. 'store_id' => $this->store_id,
  28. ];
  29. }
  30. /**
  31. * 指定 搜索索引中存储的唯一ID
  32. * @return mixed
  33. */
  34. public function getScoutKey()
  35. {
  36. return $this->id;
  37. }
  38. /**
  39. * 指定 搜索索引中存储的唯一ID的键名
  40. * @return string
  41. */
  42. public function getScoutKeyName()
  43. {
  44. return 'id';
  45. }
  46. }