ScenicSpot.php 882 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace App\Models\Manager;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. /**
  6. * 景区模型
  7. */
  8. class ScenicSpot extends Model
  9. {
  10. use HasFactory;
  11. protected $table = 'scenic_spot';
  12. public $timestamps = false;
  13. protected $connection = 'mysql';
  14. /**
  15. * 添加数据
  16. */
  17. public function add($data)
  18. {
  19. $data['insert_time'] = time();
  20. $data['update_time'] = time();
  21. $id = $this->query()->insertGetId($data);
  22. if (!$id) {
  23. return 0;
  24. }
  25. return $id;
  26. }
  27. /**
  28. * 更新数据
  29. */
  30. public function edit($id, $data)
  31. {
  32. $data['update_time'] = time();
  33. $result = $this->query()->where([['id', '=', $id]])->update($data);
  34. if (!$result) {
  35. return 0;
  36. }
  37. return $id;
  38. }
  39. }