|
@@ -0,0 +1,37 @@
|
|
|
+<?php
|
|
|
+/**
|
|
|
+ * Created by PhpStorm.
|
|
|
+ * User: durong
|
|
|
+ * Date: 2019/7/4
|
|
|
+ * Time: 上午9:50
|
|
|
+ */
|
|
|
+namespace App\Repositories;
|
|
|
+
|
|
|
+use App\Models\PostMusic;
|
|
|
+use App\Models\PostMusicCategoryRel;
|
|
|
+
|
|
|
+class MusicRepository
|
|
|
+{
|
|
|
+ public function __construct(PostMusicCategoryRel $postMusicCategoryRel)
|
|
|
+ {
|
|
|
+ $this->postMusicCategoryRel = $postMusicCategoryRel;
|
|
|
+ }
|
|
|
+
|
|
|
+ //热门音乐列表
|
|
|
+ public function lists($request)
|
|
|
+ {
|
|
|
+ $perPage = isset($request['per_page']) ? $request['per_page'] : 20;
|
|
|
+
|
|
|
+ $this->postMusicCategoryRel = $this->postMusicCategoryRel
|
|
|
+ ->join('post_music_category', 'post_music_category.id', '=', 'post_music_category_rel.music_category_id')
|
|
|
+ ->join('post_music', 'post_music.id', '=', 'post_music_category_rel.mid')
|
|
|
+ ->select('post_music.*')
|
|
|
+ ->where('post_music_category.id', 11)
|
|
|
+ ->orderBy('id', 'desc')
|
|
|
+ ->paginate($perPage);
|
|
|
+
|
|
|
+ return $this->postMusicCategoryRel;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|