LeadNotice.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace App\Models\Api\Website;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. /**
  6. * 通知成员
  7. * @author: 唐远望
  8. * @version: 1.0
  9. * @date: 2026-03-06
  10. */
  11. class LeadNotice extends Model
  12. {
  13. use HasFactory;
  14. // 与模型关联的表名
  15. protected $table = 'website_lead_notice';
  16. // 是否主动维护时间戳
  17. public $timestamps = false;
  18. // 定义时间戳字段名
  19. // const CREATED_AT = 'insert_time';
  20. // const UPDATED_AT = 'update_time';
  21. protected $connection = 'mysql';
  22. /**
  23. * 添加数据
  24. *
  25. */
  26. public function add($data)
  27. {
  28. // 时间
  29. $data['insert_time'] = time();
  30. $data['update_time'] = time();
  31. // 写入数据表
  32. $id = $this->query()->insertGetId($data);
  33. // 返回结果
  34. return $id;
  35. }
  36. /**
  37. * 添加数据
  38. *
  39. */
  40. public function edit($id,$data)
  41. {
  42. // 更新时间
  43. $data['update_time'] = time();
  44. // 写入数据表
  45. $result = $this->query()->where(['id'=>$id])->update($data);
  46. // 返回结果
  47. return $result;
  48. }
  49. /**
  50. * 获取单个信息
  51. *
  52. */
  53. public function getOne($id,$field=''){
  54. // 返回结果
  55. $result = $this->query()->find($id);
  56. // 返回结果
  57. $result = $result ? $result->toArray() : [];
  58. // 返回值
  59. return empty($field) ? $result : ( isset($result[$field]) ? $result[$field] : null);
  60. }
  61. /**
  62. * 获取单个信息
  63. *
  64. */
  65. public function getList(){
  66. // 返回结果
  67. $list = $this->query()->where([['status','=',0]])->get(['id','phone'])->toArray();
  68. // 返回值
  69. return $list;
  70. }
  71. }