I'm trying to make a checkout flow for a webshop. I'm currently on the page where the articles are shown and there is a form where a name can be written, a telephone number, an email and a personal message (It's for gifts). When the shoppingcart is loaded and the form is filled in, it's not allowed to be posted in the database for an order. But the data has to be sended to the next page so it can be called in the controller to be stored in the database. (I hope you're still with me). But I have no clue how I can store my form values into localstorage. I tried some stuff with requests but it returns null.. Anyone with an ID?
My Controller:
use Darryldecode\Cart\Facades\CartFacade as Cart;
use Illuminate\Http\Request;
use app\Models\Article;
use App\Models\Category;
use App\Models\Order;
use App\Models\Website;
use Illuminate\Support\Facades\App;
use Mollie\Laravel\Facades\Mollie;
class PayController extends Controller
{
public function additional(Request $r)
{
$articles = Article::all();
$categories = Category::all();
$websites = Website::all();
$cartItems = Cart::session(auth()->user()->id)->getContent();
$cartTotal = Cart::session(auth()->user()->id)->getTotal();
$name = $r->input('pb');
$r->session()->put('cusnaam', 'value');
$r->session()->put('tel', 'Tel');
$r->session()->put('email', 'Email');
$r->session()->flash('pb', $r->input('pb'));
return view('customer-info', compact('articles', 'categories', 'websites', 'cartItems', 'cartTotal'));
}
public function checkout(Request $r)
{
dd($r->session()->get('pb'));
}
My form:
<form action="{{ route('checkout') }}" method="post" class=" m-auto rounded-md space-y-4">
@csrf
<div class="flex wrap flex-col justify-between">
<label for="text" class="">Naam</label>
<input type="text" required class="bg-slate-100 h-fit p-2 focus:outline-sky-500 rounded" name="Cus" id="cusnaam">
</div>
<div class="flex wrap flex-col justify-between">
<label for="text" class="">Telefoonnummer</label>
<input type="text" required class="bg-slate-100 h-fit p-2 focus:outline-sky-500 rounded" name="Tel" id="tel">
</div>
<div class="flex wrap flex-col justify-between">
<label for="text" class="">Emailadres</label>
<input type="text" required class="bg-slate-100 h-fit p-2 focus:outline-sky-500 rounded" name="Email" id="email">
</div>
<div class="flex wrap flex-col justify-between pb-4 border-b">
<label for="text" class="">Persoonlijke boodschap</label>
<textarea required class="bg-slate-100 h-fit p-2 focus:outline-sky-500 rounded" name="pb" id="pb" rows="6" cols="50"></textarea>
</div>
<div class="flex flex-row justify-end items-center gap-x-10 w-full ">
<p class=" text-2xl font-bold text-green-500">Totaal: €{{ $cartTotal }}</p>
<a href="{{ route('checkout') }}" class="bg-fuchsia-400 p-2 w-3/12 hover:bg-fuchsia-600 hover:text-white text-center"><button type="submit" class="">Afrekenen</button></a>
</div>
</form>
```