MasterModel.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Models\Fpdx;
  3. use App\Models\Model;
  4. /**
  5. * App\Models\Fpdx\MasterModel
  6. *
  7. * @property int $id 主键
  8. * @property \Illuminate\Support\Carbon $created_at 创建时间
  9. * @property \Illuminate\Support\Carbon $updated_at 更新时间
  10. * @property int $uid 房主id
  11. * @property int $thumbs 点赞数
  12. * @property int $cps cp数
  13. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\MasterModel newModelQuery()
  14. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\MasterModel newQuery()
  15. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\MasterModel query()
  16. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\MasterModel whereCps($value)
  17. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\MasterModel whereCreatedAt($value)
  18. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\MasterModel whereId($value)
  19. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\MasterModel whereThumbs($value)
  20. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\MasterModel whereUid($value)
  21. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\MasterModel whereUpdatedAt($value)
  22. * @mixin \Eloquent
  23. */
  24. class MasterModel extends Model
  25. {
  26. public $table = "kdgx_fpdx_masters";
  27. public $dateFormat = 'U';
  28. protected $fillable = ["id", 'uid', 'thumbs', 'cps'];
  29. /**
  30. * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
  31. */
  32. public function user()
  33. {
  34. return $this->belongsTo(\App\Models\User\UserModel::class, 'uid', 'uid');
  35. }
  36. /**
  37. * @param int $uid
  38. * @return MasterModel|\Illuminate\Database\Eloquent\Model|null|object
  39. */
  40. public function getMaster(int $uid)
  41. {
  42. $master = $this->firstOrCreate(['uid' => $uid]);
  43. return $master;
  44. }
  45. }