diff --git a/app/Http/Controllers/CheckoutController.php b/app/Http/Controllers/CheckoutController.php new file mode 100644 index 0000000..5e76725 --- /dev/null +++ b/app/Http/Controllers/CheckoutController.php @@ -0,0 +1,71 @@ +checkoutRepository = $checkoutRepository; + } + /** + * Display a listing of the resource. + */ + public function index(ProductCheckoutRequest $request) + { + $cheeckoutProducts = $this->checkoutRepository->getCheckoutProducts($request->all()); + } + + /** + * Show the form for creating a new resource. + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + // + } + + /** + * Display the specified resource. + */ + public function show(string $id) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(string $id) + { + // + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + // + } +} diff --git a/app/Http/Requests/ProductCheckoutRequest.php b/app/Http/Requests/ProductCheckoutRequest.php new file mode 100644 index 0000000..10e72f0 --- /dev/null +++ b/app/Http/Requests/ProductCheckoutRequest.php @@ -0,0 +1,30 @@ +|string> + */ + public function rules(): array + { + return [ + 'buyer_id' => ['required', 'bail', 'integer'], + 'product_id' => ['required', 'bail', 'integer'], + 'quantity' => ['required', 'bail', 'integer'] + ]; + } +} diff --git a/app/Providers/RepositoryServiceProvider.php b/app/Providers/RepositoryServiceProvider.php index 79d5b03..31c1085 100644 --- a/app/Providers/RepositoryServiceProvider.php +++ b/app/Providers/RepositoryServiceProvider.php @@ -5,9 +5,11 @@ use App\Repositories\AdminCategoryRepository; use App\Repositories\CartRepository; +use App\Repositories\CheckoutRepository; use App\Repositories\CommentRepository; use App\Repositories\Interfaces\AdminCategoryRepositoryInterface; use App\Repositories\Interfaces\CartRepositoryInterface; +use App\Repositories\Interfaces\CheckoutRepositoryInterface; use App\Repositories\Interfaces\CommentRepositoryInterface; use App\Repositories\Interfaces\ProductRepositoryInterface; use App\Repositories\Interfaces\SellerProductRepositoryInterface; @@ -30,6 +32,7 @@ public function register(): void $this->app->bind(AdminCategoryRepositoryInterface::class, AdminCategoryRepository::class); $this->app->bind(UserRepositoryInterface::class, UserRepository::class); $this->app->bind(CartRepositoryInterface::class, CartRepository::class); + $this->app->bind(CheckoutRepositoryInterface::class, CheckoutRepository::class); } /** diff --git a/app/Repositories/CartRepository.php b/app/Repositories/CartRepository.php index b4a5edd..73862df 100644 --- a/app/Repositories/CartRepository.php +++ b/app/Repositories/CartRepository.php @@ -70,8 +70,6 @@ public function updateQuantity(array $data): bool $cartItem->save(); return true; }catch (\Exception $e){ - DB::rollBack(); - dd($e->getMessage()); Log::error('Caught Exception: ' . $e->getMessage()); Log::error('Exception Details: ' . $e); return false; diff --git a/app/Repositories/CheckoutRepository.php b/app/Repositories/CheckoutRepository.php new file mode 100644 index 0000000..75308b1 --- /dev/null +++ b/app/Repositories/CheckoutRepository.php @@ -0,0 +1,15 @@ +onUpdate('cascade') ->onDelete('cascade'); - $table->unsignedBigInteger('seller_id'); - $table->foreign('seller_id')->references('id') - ->on('users') - ->onUpdate('cascade') - ->onDelete('cascade'); - $table->unsignedBigInteger('buyer_id'); - $table->foreign('seller_id')->references('id') + $table->foreign('buyer_id')->references('id') ->on('users') ->onUpdate('cascade') ->onDelete('cascade'); - $table->unsignedTinyInteger('quantity'); - - $table->unsignedSmallInteger('total_amount'); - - $table->string('state'); - $table->timestamps(); }); } diff --git a/database/migrations/2024_03_20_030104_order_products.php b/database/migrations/2024_03_20_030104_order_products.php new file mode 100644 index 0000000..a312bdf --- /dev/null +++ b/database/migrations/2024_03_20_030104_order_products.php @@ -0,0 +1,36 @@ +id(); + + $table->unsignedBigInteger('order_id'); + $table->foreign('order_id')->on('orders') + ->references('id') + ->onDelete('cascade'); + + $table->integer('quantity'); + $table->decimal('price', 8, 2); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // + } +}; diff --git a/resources/views/userend/checkout-page.blade.php b/resources/views/userend/checkout-page.blade.php new file mode 100644 index 0000000..c283574 --- /dev/null +++ b/resources/views/userend/checkout-page.blade.php @@ -0,0 +1,5 @@ +@extends('userend.layouts.index-template') + +@section('page-title') + Brand-Product Checkout +@endsection diff --git a/resources/views/userend/product-page.blade.php b/resources/views/userend/product-page.blade.php index d8a719d..a3ce0dd 100644 --- a/resources/views/userend/product-page.blade.php +++ b/resources/views/userend/product-page.blade.php @@ -32,12 +32,17 @@ @else