diff --git a/app/Http/Controllers/CheckoutController.php b/app/Http/Controllers/CheckoutController.php index 8e0c083..bf1e24e 100644 --- a/app/Http/Controllers/CheckoutController.php +++ b/app/Http/Controllers/CheckoutController.php @@ -2,6 +2,8 @@ namespace App\Http\Controllers; +use App\Models\Checkout; +use App\Http\Controllers\Controller; use Illuminate\Http\Request; class CheckoutController extends Controller @@ -14,33 +16,27 @@ public function index() return view('frontend.checkout'); } + /** + * Show the form for creating a new resource. + */ + public function create() + { + // + } + /** * Store a newly created resource in storage. */ public function store(Request $request) { try { - $instructor = new Instructor; - $instructor->name_en = $request->fullName_en; - $instructor->name_bn = $request->fullName_bn; - $instructor->contact_en = $request->contactNumber_en; - $instructor->contact_bn = $request->contactNumber_bn; - $instructor->email = $request->emailAddress; - $instructor->role_id = $request->roleId; - $instructor->bio = $request->bio; - $instructor->designation = $request->designation; - $instructor->title = $request->title; - $instructor->status = $request->status; - $instructor->password = Hash::make($request->fullName_bn); - $instructor->language = 'en'; - $instructor->access_block = $request->access_block; - - if ($request->hasFile('image')) { - $imageName = rand(111, 999) . time() . '.' . $request->image->extension(); - $request->image->move(public_path('uploads/instructors'), $imageName); - $instructor->image = $imageName; - } - if ($instructor->save()) + $checkout = new Checkout; + $checkout->cart_data = $request->base64_encode(json_encode(session('cart'))); + $checkout->payer_name = $request->payer_name; + $checkout->payment_option = $request->payment_option; + $checkout->status = $request->status; + + if ($checkout->save()) return redirect()->route('instructor.index')->with('success', 'Data Saved'); else return redirect()->back()->withInput()->with('error', 'Please try again'); @@ -49,4 +45,36 @@ public function store(Request $request) return redirect()->back()->withInput()->with('error', 'Please try again'); } } + + /** + * Display the specified resource. + */ + public function show(Checkout $checkout) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(Checkout $checkout) + { + // + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, Checkout $checkout) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(Checkout $checkout) + { + // + } } diff --git a/app/Http/Controllers/CheckoutController2.php b/app/Http/Controllers/CheckoutController2.php new file mode 100644 index 0000000..8e0c083 --- /dev/null +++ b/app/Http/Controllers/CheckoutController2.php @@ -0,0 +1,52 @@ +name_en = $request->fullName_en; + $instructor->name_bn = $request->fullName_bn; + $instructor->contact_en = $request->contactNumber_en; + $instructor->contact_bn = $request->contactNumber_bn; + $instructor->email = $request->emailAddress; + $instructor->role_id = $request->roleId; + $instructor->bio = $request->bio; + $instructor->designation = $request->designation; + $instructor->title = $request->title; + $instructor->status = $request->status; + $instructor->password = Hash::make($request->fullName_bn); + $instructor->language = 'en'; + $instructor->access_block = $request->access_block; + + if ($request->hasFile('image')) { + $imageName = rand(111, 999) . time() . '.' . $request->image->extension(); + $request->image->move(public_path('uploads/instructors'), $imageName); + $instructor->image = $imageName; + } + if ($instructor->save()) + return redirect()->route('instructor.index')->with('success', 'Data Saved'); + else + return redirect()->back()->withInput()->with('error', 'Please try again'); + } catch (Exception $e) { + // dd($e); + return redirect()->back()->withInput()->with('error', 'Please try again'); + } + } +} diff --git a/app/Models/Checkout.php b/app/Models/Checkout.php new file mode 100644 index 0000000..63cbf9c --- /dev/null +++ b/app/Models/Checkout.php @@ -0,0 +1,11 @@ +id(); + $table->string('cart_data'); + $table->string('payer_name'); + $table->enum('payment_option', ['one_time', 'subscription'])->default('one_time'); + $table->boolean('status')->default(1)->comment('1 active, 0 inactive'); + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('checkouts'); + } +}; diff --git a/resources/views/backend/coupon/edit.blade.php b/resources/views/backend/coupon/edit.blade.php index d25f941..cd83e91 100644 --- a/resources/views/backend/coupon/edit.blade.php +++ b/resources/views/backend/coupon/edit.blade.php @@ -85,7 +85,7 @@