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 []; }
public function getVisible() { return Producer::where('hide', false)->with(['sources', 'producers'])->get(); }