created checkout controller
Cette révision appartient à :
Parent
3707c78e45
révision
9dc9d571b2
@ -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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
52
app/Http/Controllers/CheckoutController2.php
Fichier normal
52
app/Http/Controllers/CheckoutController2.php
Fichier normal
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CheckoutController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('frontend.checkout');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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())
|
||||
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
11
app/Models/Checkout.php
Fichier normal
11
app/Models/Checkout.php
Fichier normal
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Checkout extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
32
database/migrations/2023_12_09_170943_create_checkouts_table.php
Fichier normal
32
database/migrations/2023_12_09_170943_create_checkouts_table.php
Fichier normal
@ -0,0 +1,32 @@
|
||||
<?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('checkouts', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
};
|
||||
@ -85,7 +85,7 @@
|
||||
</div>
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
<button type="submit" class="btn btn-light">Cencel</button>
|
||||
<button type="submit" class="btn btn-light">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@ -236,7 +236,7 @@
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Status</label>
|
||||
<label class="form-label">Status</label>
|
||||
<select class="form-control" name="status">
|
||||
<option value="1" @if(old('status')==1) selected @endif>Active</option>
|
||||
<option value="0" @if(old('status')==0) selected @endif>Inactive</option>
|
||||
|
||||
@ -29,26 +29,32 @@
|
||||
aria-labelledby="pills-checkout-tab">
|
||||
<form action="#">
|
||||
<div class="mb-3">
|
||||
<label for="card-name-one">Name on Card</label>
|
||||
<input type="text" class="form-control" placeholder="Type here"
|
||||
id="card-name-one" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="card-number-one">Card Number</label>
|
||||
<input type="text" class="form-control" placeholder="Type here"
|
||||
id="card-number-one" />
|
||||
<label for="payer_name">Name on Card</label>
|
||||
<input type="text" class="form-control" name="payer_name" placeholder="Type here" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3 mb-lg-0">
|
||||
<label for="expiration-date-one">Expiration Date (MM/YY)</label>
|
||||
<input type="text" class="form-control" placeholder="Type here"
|
||||
id="expiration-date-one" />
|
||||
<label for="payment_option">Payment Options</label>
|
||||
<div class="form-check d-flex align-items-center ps-0">
|
||||
<input type="checkbox" id="one_time" />
|
||||
<label class="form-check-label ms-2 mb-0" for="one_time">
|
||||
One Time
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check d-flex align-items-center ps-0">
|
||||
<input type="checkbox" id="subscription" />
|
||||
<label class="form-check-label ms-2 mb-0" for="subscription">
|
||||
Subscription
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="cvc-one">CVC</label>
|
||||
<input type="text" class="form-control" id="cvc-one"
|
||||
placeholder="Type here" />
|
||||
<label for="status">Status</label>
|
||||
<select class="form-control" name="status">
|
||||
<option value="1" class="form-control" @if(old('status')==1) selected @endif>Active</option>
|
||||
<option value="0" class="form-control" @if(old('status')==0) selected @endif>Inactive</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -106,11 +112,11 @@
|
||||
</li>
|
||||
<li>
|
||||
<p>Coupon Discount</p>
|
||||
<p>15%</p>
|
||||
<p>0%</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>taxes</p>
|
||||
<p>$9.99</p>
|
||||
<p>$0.00</p>
|
||||
</li>
|
||||
<li>
|
||||
<p class="font-title--card">Total:</p>
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
use App\Http\Controllers\Backend\Communication\MessageController as message;
|
||||
use App\Http\Controllers\CartController;
|
||||
use App\Http\Controllers\HomeController;
|
||||
use App\Http\Controllers\CheckoutController;
|
||||
use App\Http\Controllers\CheckoutController as checkout;
|
||||
use App\Http\Controllers\CouponController as coupon;
|
||||
|
||||
/* students */
|
||||
@ -120,8 +120,8 @@
|
||||
// })->name('instructorProfile');
|
||||
|
||||
Route::get('instructorProfile/{id}', [instructor::class, 'frontShow'])->name('instructorProfile');
|
||||
Route::get('checkout', [CheckoutController::class, 'index'])->name('checkout');
|
||||
Route::post('checkout', [CheckoutController::class, 'store'])->name('checkout.store');
|
||||
Route::get('checkout', [checkout::class, 'index'])->name('checkout');
|
||||
Route::post('checkout', [checkout::class, 'store'])->name('checkout.store');
|
||||
|
||||
|
||||
|
||||
|
||||
Chargement…
Référencer dans un nouveau ticket
Block a user