123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Database\Eloquent\Model;
- class Store extends Model{
- use SoftDeletes;
- protected $connection = 'mysql_w';
- protected $table='store';
- protected $guarded=[];
- 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'];
- public function user(){
- return $this->belongsTo(User::class,'user_id');
- }
- public function useraa(){
- return $this->hasOne(User::class,'id','user_id');
- }
- public function address(){
- return $this->belongsTo(AddressW::class,'address_id');
- }
- public function address_store(){
- return $this->hasOne(AddressW::class,'store_id');
- }
- public function getIntegralAttribute($value){
- return round($value);
- }
- public static function getTest(){
- return [];
- }
- //测试
- // public function getNameAttribute($value){
- // return '【 '.$value.' 】';
- // }
- //
- // protected $appends = ['info'];
- //
- // public function getInfoAttribute()
- // {
- // return $this->user_id.'-'.$this->name.'-'.$this->attributes['name'];
- // }
- //
- // public function setNameAttribute($value)
- // {
- // $this->attributes['name']='【'.$value.'】';
- // }
- }
|