12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- class TopicGoods extends Model
- {
- use HasFactory;
- protected $table = 'topic_goods';
- public $timestamps = false;
- protected static $unguarded = true;
- /**
- * 专题商品列表
- * */
- public static function topicGoodsList($topicId, $page, $pageSize)
- {
- $goodsModel = self::where('enable', 1)->where('topic_id', $topicId);
- $count = $goodsModel->count();
- $itemIds = $goodsModel->select('item_id')
- ->orderBy('sort_num', 'desc')
- ->offset(($page-1) * $pageSize)
- ->limit($pageSize)
- ->pluck('item_id')
- ->toArray();
- return [$itemIds, $count];
- }
- }
|