diff --git a/app/Models/Shop/Article.php b/app/Models/Shop/Article.php index 3487ef3f..37d3c294 100644 --- a/app/Models/Shop/Article.php +++ b/app/Models/Shop/Article.php @@ -123,7 +123,7 @@ class Article extends Model implements HasMedia public function scopeWithAvailableOffers($query, $sale_channel_id = false) { return $query->whereHas('offers', function ($query) use ($sale_channel_id) { - $query->active()->bySaleChannel($sale_channel_id); + $query->active()->byStockAvailable()->bySaleChannel($sale_channel_id); }); } diff --git a/app/Models/Shop/Offer.php b/app/Models/Shop/Offer.php index 72c6ac4f..c5e3eb47 100644 --- a/app/Models/Shop/Offer.php +++ b/app/Models/Shop/Offer.php @@ -97,6 +97,11 @@ class Offer extends Model return $query->where($this->table . '.variation_id', $id); } + public function scopeByStockAvailable($query) + { + return $query->where($this->table . '.stock_current', '>', 0); + } + public function scopeByArticleNature($query, $article_nature_id) { return $query->whereHas('article.article_nature', function ($query) use ($article_nature_id) { @@ -145,5 +150,4 @@ class Offer extends Model $query->active()->bySaleChannel($sale_channel_id); }); } - } diff --git a/app/Repositories/Shop/Articles.php b/app/Repositories/Shop/Articles.php index a3ae54b3..c5988fd2 100644 --- a/app/Repositories/Shop/Articles.php +++ b/app/Repositories/Shop/Articles.php @@ -143,6 +143,9 @@ class Articles 'product', 'article_nature', 'offers.variation.package', + 'offers.tariff.price_lists' => function($query) use ($sale_channel_id) { + $query->bySaleChannel($sale_channel_id); + }, 'offers.tariff.price_lists.price_list_values', ])->get(); } diff --git a/database/migrations/2020_04_20_212813_create_activity_log_table.php b/database/migrations/2020_04_20_212813_create_activity_log_table.php deleted file mode 100644 index 1c5d4777..00000000 --- a/database/migrations/2020_04_20_212813_create_activity_log_table.php +++ /dev/null @@ -1,42 +0,0 @@ -bigInteger('id', true)->unsigned(); - $table->string('log_name')->nullable()->index(); - $table->text('description', 65535); - $table->bigInteger('subject_id')->unsigned()->nullable(); - $table->string('subject_type')->nullable(); - $table->bigInteger('causer_id')->unsigned()->nullable(); - $table->string('causer_type')->nullable(); - $table->text('properties', 65535)->nullable(); - $table->timestamps(); - $table->index(['subject_id','subject_type'], 'subject'); - $table->index(['causer_id','causer_type'], 'causer'); - }); - } - - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('activity_log'); - } - -} diff --git a/database/migrations/2020_04_20_212813_create_categories_table.php b/database/migrations/2020_04_20_212813_create_categories_table.php deleted file mode 100644 index db9a36b3..00000000 --- a/database/migrations/2020_04_20_212813_create_categories_table.php +++ /dev/null @@ -1,41 +0,0 @@ -increments('id'); - $table->string('slug')->unique(); - $table->text('name', 65535); - $table->text('description', 65535)->nullable(); - $table->integer('_lft')->unsigned()->default(0); - $table->integer('_rgt')->unsigned()->default(0); - $table->integer('parent_id')->unsigned()->nullable(); - $table->timestamps(); - $table->softDeletes(); - $table->index(['_lft','_rgt','parent_id']); - }); - } - - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('categories'); - } - -} diff --git a/database/migrations/2020_04_20_212813_create_categorizables_table.php b/database/migrations/2020_04_20_212813_create_categorizables_table.php deleted file mode 100644 index 1f447817..00000000 --- a/database/migrations/2020_04_20_212813_create_categorizables_table.php +++ /dev/null @@ -1,37 +0,0 @@ -integer('category_id')->unsigned(); - $table->string('categorizable_type'); - $table->bigInteger('categorizable_id')->unsigned(); - $table->timestamps(); - $table->unique(['category_id','categorizable_id','categorizable_type'], 'categorizables_ids_type_unique'); - $table->index(['categorizable_type','categorizable_id']); - }); - } - - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('categorizables'); - } - -}