RoomProfileModel.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace App\Models\Fpdx;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * App\Models\Fpdx\RoomProfileModel
  6. *
  7. * @property int $id 主键
  8. * @property int $uid 用户id
  9. * @property int $room_id 房间id
  10. * @property int $is_into_notive 进房提醒
  11. * @property int $is_receive_msg 接收消息
  12. * @property int|null $last_pull_msg 上一条拉取的msg_id
  13. * @property int|null $last_clear_msg 清空的最近的msg_id
  14. * @property int|null $created_at 创建时间
  15. * @property int|null $forbid 禁止发言
  16. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomProfileModel newModelQuery()
  17. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomProfileModel newQuery()
  18. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomProfileModel query()
  19. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomProfileModel whereCreatedAt($value)
  20. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomProfileModel whereForbid($value)
  21. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomProfileModel whereId($value)
  22. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomProfileModel whereIsIntoNotive($value)
  23. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomProfileModel whereIsReceiveMsg($value)
  24. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomProfileModel whereLastClearMsg($value)
  25. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomProfileModel whereLastPullMsg($value)
  26. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomProfileModel whereRoomId($value)
  27. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Fpdx\RoomProfileModel whereUid($value)
  28. * @mixin \Eloquent
  29. */
  30. class RoomProfileModel extends Model
  31. {
  32. protected $table = 'fpdx_user_profile';
  33. public $timestamps = false;
  34. protected $primaryKey = 'id';
  35. protected $fillable = [
  36. 'id',
  37. 'uid',
  38. 'room_id',
  39. 'is_into_notive',
  40. 'is_receive_msg',
  41. 'last_pull_msg',
  42. 'last_clear_msg',
  43. 'forbid',
  44. 'created_at'
  45. ];
  46. /**
  47. * 获取某人某房间的设置
  48. * @param int $room_id
  49. * @param int $uid
  50. * @return Model
  51. * @deprecated
  52. */
  53. public function profile(int $room_id, int $uid)
  54. {
  55. try {
  56. $profile = RoomProfileModel::firstOrCreate([
  57. 'uid' => $uid,
  58. 'room_id' => $room_id
  59. ], ['created_at' => time()]);
  60. return $profile;
  61. } catch (\Exception $e) {
  62. $model = new RoomProfileModel();
  63. $model->fill(array(
  64. 'uid' => $uid,
  65. 'room_id' => $room_id,
  66. 'created_at' => time(),
  67. 'is_into_notive' => 1,
  68. 'is_receive_msg' => 1,
  69. 'last_pull_msg' => 0,
  70. 'last_clear_msg' => 0,
  71. 'forbid' => 0
  72. ));
  73. return $model;
  74. }
  75. }
  76. }