Skip to content

Commit 24e5401

Browse files
Merge pull request bagisto#7712 from shivendra-webkul/review-migration
Rename table product_review_images
2 parents 7317773 + 88c94b2 commit 24e5401

9 files changed

+49
-13
lines changed

packages/Webkul/Product/src/Contracts/ProductReviewImage.php renamed to packages/Webkul/Product/src/Contracts/ProductReviewAttachment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
namespace Webkul\Product\Contracts;
44

5-
interface ProductReviewImage
5+
interface ProductReviewAttachment
66
{
77
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Webkul\Product\Database\Migrations;
4+
5+
use Illuminate\Database\Migrations\Migration;
6+
use Illuminate\Database\Schema\Blueprint;
7+
use Illuminate\Support\Facades\Schema;
8+
9+
return new class extends Migration
10+
{
11+
/**
12+
* Run the migrations.
13+
*/
14+
public function up(): void
15+
{
16+
Schema::table('product_review_images', function (Blueprint $table) {
17+
$table->string('type')->default('image')->change();
18+
});
19+
20+
Schema::rename('product_review_images', 'product_review_attachments');
21+
}
22+
23+
/**
24+
* Reverse the migrations.
25+
*/
26+
public function down(): void
27+
{
28+
Schema::table('product_review_images', function (Blueprint $table) {
29+
$table->string('type')->nullable()->change();
30+
});
31+
32+
Schema::rename('product_review_attachments', 'product_review_images');
33+
}
34+
};

packages/Webkul/Product/src/Models/ProductReview.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function product(): BelongsTo
4646
*/
4747
public function images(): HasMany
4848
{
49-
return $this->hasMany(ProductReviewImageProxy::modelClass(), 'review_id');
49+
return $this->hasMany(ProductReviewAttachmentProxy::modelClass(), 'review_id');
5050
}
5151

5252
/**

packages/Webkul/Product/src/Models/ProductReviewImage.php renamed to packages/Webkul/Product/src/Models/ProductReviewAttachment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
use Illuminate\Database\Eloquent\Model;
66
use Illuminate\Support\Facades\Storage;
7-
use Webkul\Product\Contracts\ProductReviewImage as ProductReviewImageContract;
7+
use Webkul\Product\Contracts\ProductReviewAttachment as ProductReviewAttachmentContract;
88

9-
class ProductReviewImage extends Model implements ProductReviewImageContract
9+
class ProductReviewAttachment extends Model implements ProductReviewAttachmentContract
1010
{
1111
public $timestamps = false;
1212

packages/Webkul/Product/src/Models/ProductReviewImageProxy.php renamed to packages/Webkul/Product/src/Models/ProductReviewAttachmentProxy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Konekt\Concord\Proxies\ModelProxy;
66

7-
class ProductReviewImageProxy extends ModelProxy
7+
class ProductReviewAttachmentProxy extends ModelProxy
88
{
99

1010
}

packages/Webkul/Product/src/Providers/ModuleServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ModuleServiceProvider extends CoreModuleServiceProvider
2323
\Webkul\Product\Models\ProductOrderedInventory::class,
2424
\Webkul\Product\Models\ProductPriceIndex::class,
2525
\Webkul\Product\Models\ProductReview::class,
26-
\Webkul\Product\Models\ProductReviewImage::class,
26+
\Webkul\Product\Models\ProductReviewAttachment::class,
2727
\Webkul\Product\Models\ProductSalableInventory::class,
2828
\Webkul\Product\Models\ProductVideo::class,
2929
];

packages/Webkul/Product/src/Repositories/ProductReviewImageRepository.php renamed to packages/Webkul/Product/src/Repositories/ProductReviewAttachmentRepository.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44

55
use Illuminate\Http\UploadedFile;
66
use Webkul\Core\Eloquent\Repository;
7+
use Webkul\Product\Contracts\ProductReviewAttachment;
78

8-
class ProductReviewImageRepository extends Repository
9+
class ProductReviewAttachmentRepository extends Repository
910
{
1011
/**
1112
* Specify Model class name
1213
*
1314
* @return string
1415
*/
16+
1517
function model(): string
1618
{
17-
return 'Webkul\Product\Contracts\ProductReviewImage';
19+
return ProductReviewAttachment::class;
1820
}
1921

2022
/**

packages/Webkul/Shop/src/Http/Controllers/API/ReviewController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Illuminate\Http\Resources\Json\JsonResource;
66
use Webkul\Product\Repositories\ProductRepository;
7-
use Webkul\Product\Repositories\ProductReviewImageRepository;
7+
use Webkul\Product\Repositories\ProductReviewAttachmentRepository;
88
use Webkul\Product\Repositories\ProductReviewRepository;
99
use Webkul\Shop\Http\Resources\ProductReviewResource;
1010

@@ -18,7 +18,7 @@ class ReviewController extends APIController
1818
public function __construct(
1919
protected ProductRepository $productRepository,
2020
protected ProductReviewRepository $productReviewRepository,
21-
protected ProductReviewImageRepository $productReviewImageRepository
21+
protected ProductReviewAttachmentRepository $productReviewAttachmentRepository
2222
) {
2323
}
2424

@@ -72,7 +72,7 @@ public function store($id): JsonResource
7272

7373
$review = $this->productReviewRepository->create($data);
7474

75-
$this->productReviewImageRepository->uploadImages($data, $review);
75+
$this->productReviewAttachmentRepository->uploadImages($data, $review);
7676

7777
return new JsonResource([
7878
'message' => trans('shop::app.products.submit-success'),

packages/Webkul/Shop/src/Http/Controllers/ReviewController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Webkul\Shop\Http\Controllers;
44

55
use Webkul\Product\Repositories\ProductRepository;
6-
use Webkul\Product\Repositories\ProductReviewImageRepository;
6+
use Webkul\Product\Repositories\ProductReviewAttachmentRepository;
77
use Webkul\Product\Repositories\ProductReviewRepository;
88

99
class ReviewController extends Controller
@@ -16,7 +16,7 @@ class ReviewController extends Controller
1616
public function __construct(
1717
protected ProductRepository $productRepository,
1818
protected ProductReviewRepository $productReviewRepository,
19-
protected ProductReviewImageRepository $productReviewImageRepository
19+
protected ProductReviewAttachmentRepository $productReviewAttachmentRepository
2020
) {
2121
parent::__construct();
2222
}

0 commit comments

Comments
 (0)