RoomThumbModel.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace App\Models\Fpdx;
  3. use App\Models\Model;
  4. /**
  5. * App\Models\Fpdx\RoomThumbModel
  6. *
  7. * @property int $id 主键
  8. * @property \Illuminate\Support\Carbon $created_at 创建时间
  9. * @property \Illuminate\Support\Carbon $updated_at 更新时间
  10. * @property int $uid 用户
  11. * @property int $room_id 房间id
  12. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomThumbModel newModelQuery()
  13. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomThumbModel newQuery()
  14. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomThumbModel query()
  15. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomThumbModel whereCreatedAt($value)
  16. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomThumbModel whereId($value)
  17. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomThumbModel whereRoomId($value)
  18. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomThumbModel whereUid($value)
  19. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomThumbModel whereUpdatedAt($value)
  20. * @mixin \Eloquent
  21. */
  22. class RoomThumbModel extends Model
  23. {
  24. public $table = "kdgx_fpdx_room_thumbs";
  25. public $dateFormat = 'U';
  26. protected $fillable = ['id', 'uid', 'room_id'];
  27. /**
  28. * 是否点赞
  29. * @param int $room_id
  30. * @param int $uid
  31. * @return bool
  32. */
  33. public function isThumb(int $room_id, int $uid)
  34. {
  35. $rt = RoomThumbModel::where([
  36. ['uid', $uid],
  37. ['room_id', $room_id]
  38. ])->first();
  39. if (collect($rt)->isEmpty()) {
  40. return false;
  41. } else {
  42. return true;
  43. }
  44. }
  45. }