1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2019/6/5
- * Time: 16:03
- */
- namespace App\Repositories\Circle;
- use App\Models\InterestCircle;
- use App\Models\InterestCircleArticle;
- use App\Models\InterestCircleUser;
- use App\Models\Post;
- use Illuminate\Database\QueryException;
- use Dingo\Api\Http\Response;
- use Illuminate\Support\Carbon;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Support\Facades\Redis;
- class CircleArticleRepository
- {
- public function __construct(InterestCircle $interestCircle,
- InterestCircleArticle $interestCircleArticle,
- Post $post)
- {
- $this->interestCircle = $interestCircle;
- $this->interestCircleArticle = $interestCircleArticle;
- $this->post = $post;
- }
- /**
- * 内容列表
- */
- public function lists($request)
- {
- $perPage = isset($request['per_page']) ? $request['per_page'] : 20;
- $where[] = ['interest_circle_articles.circle_id', $request['id']];
- $articleModel = $this->post;
- return $articleModel
- ->join('interest_circle_articles', 'interest_circle_articles.post_id', '=', 'post.id')
- ->select('post.*', 'interest_circle_articles.is_recommend', 'interest_circle_articles.circle_id')
- ->where($where)
- ->orderBy('interest_circle_articles.is_recommend', 'desc')
- ->orderBy('post.weight', 'desc')
- ->paginate($perPage);
- }
- }
|