/home/vrande/domains/vrande.nl/public_html/app/system/DB/Model/QueryBuilder.php
parent::__construct();
$this->model = $model;
$this->getContent()->table($model->getTable(true), $model->getTableAlias());
$this->wrap(
fn($item) => $this->model->newInstance()->fillFromSource($item)
);
}
public function qualifyColumn($column)
{
return $this->model->qualifyColumn($column);
}
public function firstOrFail()
{
if (is_null($result = $this->first())) {
throw new ModelNotFoundException(get_class($this->getModel()));
}
return $result;
}
public function newInstance(): QueryBuilder
{
return new static($this->model);
}
public function getModel(): CoreModel
{
return $this->model;
}
public function __call($name, $arguments)
{
$scopedQuery = 'query'.ucfirst($name);
if (method_exists($this->model, $scopedQuery)) {
/home/vrande/domains/vrande.nl/public_html/app/http/middleware/SetPage.php
public function run(array $parameters)
{
if ($id = App::request()->query('page_id')) {
App::setPage(Page::where('id', $id)->withoutDisabled()->firstOrFail());
} else {
// First we check if either slug, parentSlug or headSlug has been set
$slug = ($parameters['slug'] ?? $parameters['parentSlug'] ?? $parameters['headSlug'] ?? null);
$hasSlug = ($slug !== null);
// If not we try and get the nth segment of the route (i.e. /nl/{second-segment})
// In case all of these haven't worked we assume we are on Home
if ($slug === null) {
$nth = (App::request()->currentRoute()->hasParameter('lang') ? 2 : 1);
$slug = (App::request()->segment($nth) ?: 'home');
}
$page = Page::whereSlug($slug)->withoutDisabled()->firstOrFail();
// Globalize the found page
App::setPage($page);
// Globalize the head page if used
if ($hasSlug && $this->hasHead($parameters)) {
App::set('head_page', Page::whereSlug($this->getHeadSlug($parameters))->withoutDisabled()->first());
}
}
$this->setOldWebsite($page->id); // @todo: Remove when not needed anymore.
}
protected function hasHead(array $parameters): bool
{
return ($this->getHeadSlug($parameters) !== null);
}
protected function getHeadSlug(array $parameters): ?string
{
/home/vrande/domains/vrande.nl/public_html/app/system/Router/Middleware.php
if (!isset($this->middleware[$name])) {
throw new \Exception("Middleware '{$name}' has not been registered");
}
$middleware = $this->middleware[$name];
if (is_array($middleware)) {
$this->run($middleware);
}
else {
if ($this->runMiddleware($middleware, $parameters) === false) {
break;
}
}
}
}
public function runMiddleware($class, array $parameters = [])
{
return (new $class)->run($parameters);
}
}
/home/vrande/domains/vrande.nl/public_html/app/system/Router/Middleware.php
{
return $this->withGlobals(false);
}
public function run(array $names, array $parameters = [])
{
$all = ($this->runGlobals ? array_merge($this->global, $names) : $names);
foreach ($all as $name) {
if (!isset($this->middleware[$name])) {
throw new \Exception("Middleware '{$name}' has not been registered");
}
$middleware = $this->middleware[$name];
if (is_array($middleware)) {
$this->run($middleware);
}
else {
if ($this->runMiddleware($middleware, $parameters) === false) {
break;
}
}
}
}
public function runMiddleware($class, array $parameters = [])
{
return (new $class)->run($parameters);
}
}
/home/vrande/domains/vrande.nl/public_html/app/concerns/IsSingleton.php
}
public static function getInstance(): self
{
if (!isset(static::$instance)) {
static::$instance = static::newInstance();
}
return static::$instance;
}
public static function __callStatic($name, $arguments)
{
$inst = static::getInstance();
if (method_exists($inst, 'forwardCallsTo')) {
if (method_exists($inst->forwardCallsTo(), $name)) {
$class = $inst->forwardCallsTo();
return $class->{$name}(...$arguments);
}
}
}
}
/home/vrande/domains/vrande.nl/public_html/app/system/Router/Route.php
public function call()
{
App::event('route.calling', $this);
$callback = $this->callback;
$arguments = $this->prepareParameters($callback, $this->parameters);
if (is_array($callback)) {
[$controller, $method] = $callback;
return (new $controller)->{$method}(...$arguments);
}
return $callback(...$arguments);
}
public function runMiddleware(): self
{
Middleware::run($this->getMiddleware(), $this->getParameters());
return $this;
}
public function getParameters(): array
{
return $this->parameters;
}
public function hasParameter($name): bool
{
return isset($this->parameters[$name]);
}
public function hasRouteParameter($name): bool
{
$route = $this->getRoute();
return $this->remember(fn () => (new Matcher($route))->hasParameterName($name), __FUNCTION__);
}
/home/vrande/domains/vrande.nl/public_html/app/system/Router/Router.php
}
$method = App::request()->method();
if (!empty($this->routes)) {
foreach ($this->getRoutes() as $route) {
if ($route->matches($method, $this->routeUrl)) {
return $this->callRoute($route);
}
}
throw new RouteNotFoundException($this->routeUrl, $method);
}
}
protected function callRoute(Route $route)
{
$this->currentRoute = $route;
return $route->runMiddleware()->call();
}
/**
* @return Route[]
*/
public function getRoutes(): array
{
return $this->routes;
}
public function getCurrentRoute(): Route
{
return $this->currentRoute;
}
/**
* @return Route[]
*/
public static function getAllRoutes(): array
{
/home/vrande/domains/vrande.nl/public_html/app/system/Router/Router.php
$route->group($group);
}
static::$allRoutes[] = $this->routes[] = $route;
return $this;
}
public function run()
{
if ($this->disabled) {
return null;
}
$method = App::request()->method();
if (!empty($this->routes)) {
foreach ($this->getRoutes() as $route) {
if ($route->matches($method, $this->routeUrl)) {
return $this->callRoute($route);
}
}
throw new RouteNotFoundException($this->routeUrl, $method);
}
}
protected function callRoute(Route $route)
{
$this->currentRoute = $route;
return $route->runMiddleware()->call();
}
/**
* @return Route[]
*/
public function getRoutes(): array
{
return $this->routes;
/home/vrande/domains/vrande.nl/public_html/app/system/Routing.php
* @param array $arguments
* @return Route
*/
public static function delete($route, $callback, array $arguments = []): Route
{
static::getInstance()->getRouter()->add(
$route = new Route('delete', $route, $callback, $arguments)
);
return $route;
}
/**
* Try and match the given routes
* @return mixed|null
* @throws \app\exceptions\RouteNotFoundException
*/
public static function run()
{
return static::getInstance()->getRouter()->run();
}
public function getRouter(): Router
{
return $this->router;
}
/**
* Get the currently used route
* @return Route
*/
public static function getCurrentRoute(): Route
{
return static::getInstance()->getRouter()->getCurrentRoute();
}
public static function getInstance(): self
{
if (!isset(static::$instance)) {
static::$instance = new static;
/home/vrande/domains/vrande.nl/public_html/app/system/App.php
{
return static::instance()->traitRemember($callback, $key);
}
public static function set($key, $value)
{
static::instance()->setMemory($key, $value);
}
public static function get($key)
{
return static::instance()->fromMemory($key);
}
public static function run()
{
try {
static::event('booted');
return Routing::run();
} catch (Throwable $ex) {
return Kernel::handle($ex);
} finally {
Session::transferFlashed();
}
}
}
/home/vrande/domains/vrande.nl/public_html/index.php
<?php
include_once(__DIR__.'/includes/main.php');
use app\system\App;
// Backwards compatibility
$dbase->connect();
echo App::run();