Conversie codeigniter 4
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Beheer;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
||||
class VatController extends BaseController
|
||||
{
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
if (!defined('AUTHENTICATED') || AUTHENTICATED === false) {
|
||||
die('NO ACCESS');
|
||||
}
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// Default action
|
||||
}
|
||||
|
||||
public function getVats(string $archive): ResponseInterface
|
||||
{
|
||||
$vats = \Vat::getVats($archive);
|
||||
|
||||
return $this->json($vats);
|
||||
}
|
||||
|
||||
public function addVat(): ResponseInterface
|
||||
{
|
||||
\Vat::create([]);
|
||||
return $this->json(['success' => true]);
|
||||
}
|
||||
|
||||
public function saveVat(int $vatID): ResponseInterface
|
||||
{
|
||||
$vatrate = $this->request->getPost('vatrate');
|
||||
\Vat::whereId($vatID)->update(['vatrate' => $vatrate]);
|
||||
return $this->json(['success' => true]);
|
||||
}
|
||||
|
||||
public function removeVat(int $vatID): ResponseInterface
|
||||
{
|
||||
$removeVat = new \RemoveVat($vatID);
|
||||
|
||||
$allowRemove = $removeVat->getRemoveAllowed();
|
||||
|
||||
if ($allowRemove === false) {
|
||||
return $this->json(['result' => false]);
|
||||
}
|
||||
|
||||
\Vat::whereId($vatID)->delete();
|
||||
|
||||
return $this->json(['result' => true]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user