优惠券小程序

TopicInfo.php 762B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. class TopicInfo extends Model
  6. {
  7. use HasFactory;
  8. protected $table = 'topic_info';
  9. public $timestamps = false;
  10. protected static $unguarded = true;
  11. /**
  12. * 获取专题列表
  13. * */
  14. public static function topicList($page, $pageSize)
  15. {
  16. $topicModel = self::where('enable', 1);
  17. $count = $topicModel->count();
  18. $list = $topicModel->select(['id', 'topic_name', 'topic_pic', 'topic_desc', 'create_time'])
  19. ->orderBy('sort_num', 'desc')
  20. ->offset(($page-1) * $pageSize)
  21. ->limit($pageSize)
  22. ->get();
  23. return [$list, $count];
  24. }
  25. }