Rome.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Rome extends Model
  5. {
  6. protected $table = 'love_rome';
  7. protected $fillable = [
  8. 'uid', 'jid','nid', 'type', 'start','end','name','sex','sort'
  9. ];
  10. public function user(){
  11. return $this->hasOne(Users::class,'id','uid')->select('id','name', 'lid', 'avatar','sex','age','vip','trump','opt','city');
  12. }
  13. public function guest(){
  14. return $this->hasOne(Users::class,'id','jid')->select('id','name', 'lid', 'avatar','sex','age','vip','trump','opt','city');
  15. }
  16. public function manuser(){
  17. return $this->hasOne(Users::class,'id','nid')->select('id','name', 'lid', 'avatar','sex','age','vip','trump','opt','city');
  18. }
  19. public function getStartAttribute() {
  20. return date("Y-m-d H:i:s",$this->attributes['start']);
  21. }
  22. public function getEndAttribute() {
  23. return date("Y-m-d H:i:s",$this->attributes['end']);
  24. }
  25. public function applend(){
  26. return $this->hasMany(UserRomeApply::class,'rid','id');
  27. }
  28. public function gifts(){
  29. return $this->hasMany(UserGifts::class,'rid','id');
  30. }
  31. }