Add new search of articles
This commit is contained in:
@@ -14,6 +14,8 @@ class ArticleController extends Controller
|
||||
{
|
||||
$data = self::init();
|
||||
$data['article'] = Articles::getArticleToSell($id);
|
||||
// dump($data['article']);
|
||||
// exit;
|
||||
return view('Shop.Articles.show', $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class Offer extends Model
|
||||
|
||||
public function price_lists()
|
||||
{
|
||||
return $this->hasManyThrough(PriceList::class, Tariff::class, 'id', 'tariff_id', 'id', 'id');
|
||||
return $this->hasManyThrough(PriceList::class, Tariff::class, 'id', 'tariff_id', 'tariff_id', 'id');
|
||||
}
|
||||
|
||||
public function categories()
|
||||
@@ -64,7 +64,7 @@ class Offer extends Model
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->byStatus(1)->byTariffActive();
|
||||
return $query->byStatus(1)->HasTariffActive();
|
||||
}
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
@@ -132,10 +132,18 @@ class Offer extends Model
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeByTariffActive($query)
|
||||
public function scopeHasTariffActive($query)
|
||||
{
|
||||
return $query->whereHas('tariff', function ($query) {
|
||||
$query->active();
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeBySaleChannel($query, $sale_channel_id)
|
||||
{
|
||||
return $query->whereHas('price_lists', function ($query) use ($sale_channel_id) {
|
||||
$query->active()->bySaleChannel($sale_channel_id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ class Tariff extends Model
|
||||
|
||||
public function sale_channels()
|
||||
{
|
||||
// return $this->HasManyThrough(SaleChannel::class, PriceList::class);
|
||||
return $this->HasManyThrough(SaleChannel::class, PriceList::class, 'id', 'id', 'id', 'sale_channel_id');
|
||||
}
|
||||
|
||||
@@ -73,10 +72,10 @@ class Tariff extends Model
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->byStatus(0)->byPriceListsActive();
|
||||
return $query->byStatus(0)->hasPriceListsActive();
|
||||
}
|
||||
|
||||
public function scopeByPriceListsActive($query)
|
||||
public function scopeHasPriceListsActive($query)
|
||||
{
|
||||
return $query->whereHas('price_lists', function ($query) {
|
||||
$query->active();
|
||||
|
||||
@@ -7,14 +7,14 @@ use App\Models\Shop\Offer;
|
||||
class Offers
|
||||
{
|
||||
|
||||
public static function getOffersByArticles($articles_id)
|
||||
public static function getOffersByArticles($articles_ids)
|
||||
{
|
||||
return Offer::active()->with(['article_nature', 'tariff.price_lists.price_list_values', 'variation'])->byArticles($articles_id)->get();
|
||||
return Offer::active()->with(['article_nature', 'variation', 'tariff.price_lists.price_list_values'])->byArticles($articles_ids)->get();
|
||||
}
|
||||
|
||||
public static function getOffersByArticle($article_id)
|
||||
{
|
||||
return Offer::active()->with('variation')->byArticle($article_id)->get();
|
||||
return Offer::active()->with(['article_nature', 'variation', 'tariff.price_lists.price_list_values'])->byArticle($article_id)->get();
|
||||
}
|
||||
|
||||
public static function getThumbSrcById($id)
|
||||
|
||||
Reference in New Issue
Block a user