| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 | 
							- <?php
 
- /**
 
-  * Created by PhpStorm.
 
-  * User: Administrator
 
-  * Date: 2018/11/7
 
-  * Time: 18:07
 
-  */
 
- namespace App\Repositories;
 
- use App\Models\Link;
 
- use Prettus\Repository\Eloquent\BaseRepository;
 
- /**
 
-  * Class LinkRepositoryEloquent.
 
-  *
 
-  * @package namespace App\Repositories;
 
-  */
 
- class LinkRepository extends BaseRepository
 
- {
 
-     /**
 
-      * Specify Model class name
 
-      *
 
-      * @return string
 
-      */
 
-     public function model()
 
-     {
 
-         return Link::class;
 
-     }
 
-     public function getLinks($where, $limit = '')
 
-     {
 
-         /*$res = $this->model->when(get_subsite_id()>0, function ($query) {
 
-                 $query->whereHas('subsites', function ($query) { $query->where('subsite_id', get_subsite_id());});
 
-             })->where($where)->orderBy('list_order', 'asc')->orderBy('id', 'asc');*/
 
-         $res = $this->model->whereHas('subsites', function ($query) {
 
-             $query->where('subsite_id', get_subsite_id());
 
-         })->where($where)->orderBy('list_order', 'desc')->orderBy('created_at', 'desc');
 
-         if ($limit) {
 
-             $res->limit($limit);
 
-         }
 
-         return $res->get();
 
-     }
 
- }
 
 
  |