Feature/add e shop
This commit is contained in:
@@ -61,6 +61,11 @@ class Helper {
|
||||
$value = $data[$key] ?? null;
|
||||
$title = $rules['title'] ?? $key;
|
||||
|
||||
//TODO: fix this, skip arrays for now
|
||||
if (is_array($value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Apply default values for missing rules
|
||||
|
||||
$rules = array_merge([
|
||||
|
||||
@@ -23,7 +23,12 @@ class TTCrud extends mfBaseController {
|
||||
$this->user = $me;
|
||||
$this->layout()->set('me', $me);
|
||||
|
||||
if (!$me->is(["Admin"])) {
|
||||
if (method_exists($this, 'permissionCheck')) {
|
||||
$allowed = $this->permissionCheck();
|
||||
if (!$allowed) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
} else if (!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
|
||||
|
||||
@@ -68,12 +68,17 @@ class TTCrudBaseModel {
|
||||
}
|
||||
|
||||
|
||||
public static function get($id): TTCrudBaseModel {
|
||||
public static function get($id, $die= false): TTCrudBaseModel {
|
||||
$FronkDB = FronkDB::singleton();
|
||||
$db = $FronkDB->link;
|
||||
$id = $db->real_escape_string($id);
|
||||
$table = self::getTable();
|
||||
$sql = "SELECT * FROM `$table` WHERE `id` = $id";
|
||||
|
||||
if($die) {
|
||||
die($sql);
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
// as TTCRudBaseModel is abstract, we need to get the class name of the child class
|
||||
$class = get_called_class();
|
||||
@@ -148,6 +153,13 @@ class TTCrudBaseModel {
|
||||
if ($field === "id") {
|
||||
continue;
|
||||
}
|
||||
// TODO: make this cleaner
|
||||
if ($value === "" && (new ReflectionProperty(get_called_class(), $field))->getType()->getName() === "float") {
|
||||
$value = null;
|
||||
}
|
||||
if ($value === "" && (new ReflectionProperty(get_called_class(), $field))->getType()->getName() === "int") {
|
||||
$value = null;
|
||||
}
|
||||
|
||||
$values[] = $value === null ? "`$field` = NULL" : "`$field` = '" . $db->real_escape_string($value) . "'";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user