Store.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\SoftDeletes;
  4. use Illuminate\Database\Eloquent\Model;
  5. class Store extends Model{
  6. use SoftDeletes;
  7. protected $connection = 'mysql_w';
  8. protected $table='store';
  9. protected $guarded=[];
  10. protected $fillable=['img','name','user_id','content','info','phone','qr_code','is_dianjin','is_business','is_adverting','province','city','area','address','warea_id','warea_name'];
  11. public function user(){
  12. return $this->belongsTo(User::class,'user_id');
  13. }
  14. public function useraa(){
  15. return $this->hasOne(User::class,'id','user_id');
  16. }
  17. public function address(){
  18. return $this->belongsTo(AddressW::class,'address_id');
  19. }
  20. public function address_store(){
  21. return $this->hasOne(AddressW::class,'store_id');
  22. }
  23. public function getIntegralAttribute($value){
  24. return round($value);
  25. }
  26. public static function getTest(){
  27. return [];
  28. }
  29. //测试
  30. // public function getNameAttribute($value){
  31. // return '【 '.$value.' 】';
  32. // }
  33. //
  34. // protected $appends = ['info'];
  35. //
  36. // public function getInfoAttribute()
  37. // {
  38. // return $this->user_id.'-'.$this->name.'-'.$this->attributes['name'];
  39. // }
  40. //
  41. // public function setNameAttribute($value)
  42. // {
  43. // $this->attributes['name']='【'.$value.'】';
  44. // }
  45. }