Archived
lastest
This commit is contained in:
1 parent
620fc5bda1
commit
bd3ef9f279
779 files changed
+202868
No files matched your search
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\HTTP\CLIRequest;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Class BaseController
|
||||
*
|
||||
* BaseController provides a convenient place for loading components
|
||||
* and performing functions that are needed by all your controllers.
|
||||
* Extend this class in any new controllers:
|
||||
* class Home extends BaseController
|
||||
*
|
||||
* For security be sure to declare any new methods as protected or private.
|
||||
*/
|
||||
abstract class BaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* Instance of the main Request object.
|
||||
*
|
||||
* @var CLIRequest|IncomingRequest
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* An array of helpers to be loaded automatically upon
|
||||
* class instantiation. These helpers will be available
|
||||
* to all other controllers that extend BaseController.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $helpers = [];
|
||||
|
||||
/**
|
||||
* Be sure to declare properties for any property fetch you initialized.
|
||||
* The creation of dynamic property is deprecated in PHP 8.2.
|
||||
*/
|
||||
// protected $session;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
// Do Not Edit This Line
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
// Preload any models, libraries, etc, here.
|
||||
|
||||
// E.g.: $this->session = service('session');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\ItemModel;
|
||||
|
||||
class Cart extends BaseController {
|
||||
|
||||
public function index() {
|
||||
helper('cookie');
|
||||
|
||||
$data['title'] = 'Cart';
|
||||
return view('Cart/index', $data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
class Home extends BaseController
|
||||
{
|
||||
public function index(): string
|
||||
{
|
||||
$data = [
|
||||
'title' => 'Emporiko Shop'
|
||||
];
|
||||
return view('homepage', $data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\ItemModel;
|
||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||
|
||||
class Item extends BaseController {
|
||||
|
||||
public function index() {
|
||||
$model = model(ItemModel::class);
|
||||
|
||||
$data = [
|
||||
'title' => 'Emperiko Shop',
|
||||
'item' => $model->paginate(6),
|
||||
'pager' => $model->pager,
|
||||
];
|
||||
|
||||
return view('Item/index', $data);
|
||||
}
|
||||
|
||||
public function show(?string $itemId = null) {
|
||||
$model = model(ItemModel::class);
|
||||
|
||||
$data['item'] = $model->getItem($itemId);
|
||||
|
||||
$data['star'] = $model->getStar($itemId);
|
||||
|
||||
if ($data['item'] === null) {
|
||||
throw new PageNotFoundException('Cannot find requested product ID number: ' . $itemId);
|
||||
}
|
||||
|
||||
$data['title'] = $data['item']['title'];
|
||||
helper('form');
|
||||
helper('cookie');
|
||||
|
||||
|
||||
return view('Item/product', $data);
|
||||
}
|
||||
|
||||
public function set() {
|
||||
$cookie = new Cookie( [
|
||||
'expires' => new DateTime('+2 days'),
|
||||
'prefix' => '__Secure-',
|
||||
'path' => '/',
|
||||
'domain' => '',
|
||||
] );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user