public function getProductsByProducerKey($producerKey = '', $limit = 0)
 {
     $producer = Producer::where('key', $producerKey)->first();
     if (isset($producer) && !is_null($producer)) {
         if ($limit == 0) {
             return $producer->products()->where('is_publish', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get();
         } else {
             return $producer->products()->where('is_publish', 1)->orderBy('priority')->orderBy('created_at', 'desc')->take($limit)->get();
         }
     }
     return [];
 }
예제 #2
0
 public function getVisible()
 {
     return Producer::where('hide', false)->with(['sources', 'producers'])->get();
 }