123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Repositories\Behavior;
- use App\Models\BehaviorOperationLog;
- /**
- * Created by PhpStorm.
- * User: durong
- * Date: 2019/6/13
- * Time: 下午7:11
- */
- class BehaviorLogRepository
- {
- public function __construct(BehaviorOperationLog $behaviorOperationLog)
- {
- $this->behaviorOperationLog = $behaviorOperationLog;
- }
- public function log($request)
- {
- $perPage = isset($request['per_page']) ? $request['per_page'] : 20;
- $where = [];
- if(isset($request['type'])){
- $where[] = ['type', $request['type']];
- }
- return $this->behaviorOperationLog
- ->where($where)
- ->where(function($query) use ($request){
- if(isset($request['created_at'])){
- $time = explode('_', $request['created_at']);
- $query->whereBetween('created_at', $time);
- }
- })
- ->orderBy('id','desc')
- ->paginate($perPage);
- }
- }
|