-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
190 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Http\Requests\ProductCheckoutRequest; | ||
use App\Repositories\Interfaces\CheckoutRepositoryInterface; | ||
use Illuminate\Http\Request; | ||
|
||
class CheckoutController extends Controller | ||
{ | ||
protected $checkoutRepository; | ||
public function __construct(CheckoutRepositoryInterface $checkoutRepository) | ||
{ | ||
$this->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) | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class ProductCheckoutRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
*/ | ||
public function authorize(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'buyer_id' => ['required', 'bail', 'integer'], | ||
'product_id' => ['required', 'bail', 'integer'], | ||
'quantity' => ['required', 'bail', 'integer'] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Repositories; | ||
|
||
use App\Repositories\Interfaces\CheckoutRepositoryInterface; | ||
|
||
class CheckoutRepository implements CheckoutRepositoryInterface | ||
{ | ||
public function getCheckoutProducts(array $data) | ||
{ | ||
dd($data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace App\Repositories\Interfaces; | ||
|
||
interface CheckoutRepositoryInterface | ||
{ | ||
public function getCheckoutProducts(array $data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('order_products', function (Blueprint $table){ | ||
$table->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 | ||
{ | ||
// | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@extends('userend.layouts.index-template') | ||
|
||
@section('page-title') | ||
Brand-Product Checkout | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
<?php | ||
|
||
use App\Http\Controllers\CartController; | ||
use App\Http\Controllers\CheckoutController; | ||
use Illuminate\Support\Facades\Route; | ||
|
||
/** | ||
* Routes for cart operations | ||
*/ | ||
Route::middleware(['guest.authenticate'])->group(function (){ | ||
Route::get('{userId}/cart-items', [CartController::class, 'index'])->name('cart-items'); | ||
Route::post('add-to-cart', [CartController::class, 'store'])->name('add-to-cart'); | ||
Route::put('cart-quantity-change', [CartController::class, 'update'])->name('change-cart-item-quantity'); | ||
Route::post('remove-from-cart', [CartController::class, 'destroy'])->name('remove-from-cart'); | ||
}); | ||
|
||
|
||
/** | ||
* Routes for checkout operations | ||
*/ | ||
Route::middleware(['guest.authenticate'])->group(function (){ | ||
Route::post('items-checkout', [CheckoutController::class, 'index'])->name('checkout-page'); | ||
}); |