FleetCart/app/Http/Controllers/LicenseController.php

43 lines
1.0 KiB
PHP
Raw Normal View History

2023-06-11 12:14:03 +00:00
<?php
namespace FleetCart\Http\Controllers;
use FleetCart\License;
use Illuminate\Routing\Controller;
2023-12-03 14:07:47 +00:00
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\Foundation\Application;
2023-06-11 12:14:03 +00:00
use FleetCart\Http\Middleware\RedirectIfShouldNotCreateLicense;
class LicenseController extends Controller
{
public function __construct()
{
$this->middleware(RedirectIfShouldNotCreateLicense::class);
}
2023-12-03 14:07:47 +00:00
public function create(): Factory|View|Application
2023-06-11 12:14:03 +00:00
{
return view('license.create');
}
2023-12-03 14:07:47 +00:00
public function store(License $license): RedirectResponse
2023-06-11 12:14:03 +00:00
{
2023-12-03 14:07:47 +00:00
request()->validate(
[
'purchase_code' => 'required',
],
[
'required' => 'The purchase code field is required.',
]
);
2023-06-11 12:14:03 +00:00
$license->activate(request('purchase_code'));
return redirect()->intended();
}
}