Skip to content

Instantly share code, notes, and snippets.

@NandoKstroNet
Last active January 26, 2022 15:37
Show Gist options
  • Save NandoKstroNet/88469e797005e504620111e7edfb948c to your computer and use it in GitHub Desktop.
Save NandoKstroNet/88469e797005e504620111e7edfb948c to your computer and use it in GitHub Desktop.
Checkout Lojas do Projeto Laravel Tenancy em https://codeexperts.com.br/curso/laravel-tenancy-1
<x-guest-layout>
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<h3 class="text-2xl font-extrabold my-8"></h3>
<hr>
<h5 class="my-20 text-4xl text-center font-extrabold">Checkout</h5>
<hr>
<div class="w-1/2 block mx-auto mt-10">
<form action="{{route('checkout.proccess', request('subdomain'))}}" method="post">
@csrf
<div class="w-full mb-8">
<label class="block">Número Cartão</label>
<input type="text" name="card_number" class="w-full">
</div>
<div class="w-full mb-8 flex justify-between">
<div>
<label class="block">Validade</label>
<input type="text" name="card_date">
</div>
<div>
<label class="block">Código de Segurança</label>
<input type="text" name="card_cvv">
</div>
</div>
<button
class="text-xl font-bold px-4 py-2 rounded bg-green-600 text-white shadow hover:bg-green-300 transition ease-in-out delay-150 uppercase">Realizar Pagamento</button>
</form>
</div>
</div>
</x-guest-layout>
<?php
namespace App\Http\Controllers\Front;
use App\Http\Controllers\Controller;
use App\Services\CartService;
use Illuminate\Http\Request;
class CheckoutController extends Controller
{
public function checkout($subdomain, CartService $cartService)
{
if(!$cartService->all()) abort(500);
return view('front.checkout');
}
public function proccess($subdomain, CartService $cartService, Request $request)
{
if(!$cartService->all()) abort(500);
$cartService->clear();
return redirect()->route('checkout.thanks', $subdomain);
}
public function thanks($subdomain, CartService $cartService)
{
if(!$cartService->all()) abort(500);
return view('front.thanks');
}
}
<x-guest-layout>
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<h3 class="text-2xl font-extrabold my-8"></h3>
<hr>
<h5 class="my-20 text-4xl text-center font-extrabold">Obrigado</h5>
<hr>
<div class="w-1/2 block mx-auto mt-10 text-center">
<h3 class="text-3xl font-extrabold">Muito obrigado por sua compra!!</h3>
</div>
</div>
</x-guest-layout>
<?php
Route::prefix('checkout')->middleware('auth.stores')->name('checkout.')->group(function(){
Route::get('/', [\App\Http\Controllers\Front\CheckoutController::class, 'checkout'])->name('checkout');
Route::post('/proccess', [\App\Http\Controllers\Front\CheckoutController::class, 'proccess'])->name('proccess');
Route::get('/thanks', [\App\Http\Controllers\Front\CheckoutController::class, 'thanks'])->name('thanks');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment