Skip to content

Commit 96d7a11

Browse files
committed
update
1 parent 06b3e4b commit 96d7a11

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

app/Http/Controllers/Product/PublishedProductController.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,31 @@
33
namespace App\Http\Controllers\Product;
44

55
use App\Models\Product;
6+
use App\Models\FeedBack;
67
use Illuminate\Http\Request;
78
use App\Http\Controllers\Controller;
89

910
class PublishedProductController extends Controller
1011
{
11-
public function publishedProduct($id)
12+
public function publishedProduct($id,Request $request)
1213
{
1314
$product = Product::find($id);
1415
if($product->status == 0){
1516
$product->status = 1;
17+
$product->isRejet=0;
1618
$product->save();
1719
return response()->json(['message' => 'Product published successfully']);
1820
}else{
21+
if($request->message){
22+
$feedBack=new FeedBack;
23+
$feedBack->user_id=$request->user_id;
24+
$feedBack->message=$request->message;
25+
$feedBack->status=0;
26+
$feedBack->type="1";
27+
$feedBack->product_id=$product->id;
28+
$product->isRejet=1;
29+
$feedBack->save();
30+
}
1931
$product->status = 0;
2032
$product->save();
2133
return response()->json(['message' => 'Product unpublished successfully']);

app/Http/Resources/ProductResource.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public function toArray(Request $request): array
2828
"id" => $this->id,
2929
"product_name" => $this->product_name,
3030
"product_description" => $this->product_description,
31+
"isRejet"=>$this->isRejet,
3132
"shop_name" => $this->shop->shop_name,
33+
"user_id"=>$this->shop->user_id,
3234
"shop_key" => $this->shop->shop_key,
3335
"shop_created_at" => $this->shop->created_at,
3436
"product_gender" => $this->product_gender,

database/migrations/2024_11_26_191119_create_products_table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function up(): void
2929
$table->string('product_quantity')->nullable();
3030
$table->string('product_profile')->nullable();
3131
$table->boolean("status")->default(0);
32+
$table->boolean("isRejet")->default(0);
3233
$table->boolean('isSubscribe')->default(0);
3334
$table->timestamp('expire')->nullable();
3435
$table->string('subscribe_id')->nullable();

database/migrations/2025_03_14_162443_create_feed_backs_table.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public function up(): void
1717
$table->foreignIdFor(User::class)->constrained()->onDelete('cascade');
1818
$table->string("message");
1919
$table->boolean("status");
20+
$table->string("type")->default("0");
21+
$table->string("product_id")->nullable();
2022
$table->timestamps();
2123
});
2224
}

0 commit comments

Comments
 (0)