feat(main): Add slider block type
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Websmid\CustomHtml\Model;
|
||||
|
||||
use ObjectModel;
|
||||
use Db;
|
||||
|
||||
class CustomHtmlSlide extends ObjectModel
|
||||
{
|
||||
/** @var int */
|
||||
public $id;
|
||||
|
||||
/** @var int */
|
||||
public $id_ws_customhtml;
|
||||
|
||||
/** @var string */
|
||||
public $title = '';
|
||||
|
||||
/** @var string */
|
||||
public $description = '';
|
||||
|
||||
/** @var string */
|
||||
public $extra_description = '';
|
||||
|
||||
/** @var string */
|
||||
public $link = '';
|
||||
|
||||
/** @var string */
|
||||
public $link_text = '';
|
||||
|
||||
/** @var string */
|
||||
public $image = '';
|
||||
|
||||
/** @var int */
|
||||
public $ordering = 0;
|
||||
|
||||
/** @var string */
|
||||
public $date_add;
|
||||
|
||||
/** @var string */
|
||||
public $date_upd;
|
||||
|
||||
public static $definition = [
|
||||
'table' => 'ws_customhtml_slide',
|
||||
'primary' => 'id_ws_customhtml_slide',
|
||||
'fields' => [
|
||||
'id_ws_customhtml' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
|
||||
'title' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 256],
|
||||
'description' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 1024],
|
||||
'extra_description' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 1024],
|
||||
'link' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 512],
|
||||
'link_text' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 128],
|
||||
'image' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => false, 'size' => 255],
|
||||
'ordering' => ['type' => self::TYPE_INT, 'validate' => 'isInt'],
|
||||
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
|
||||
'date_upd' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
|
||||
],
|
||||
];
|
||||
|
||||
public static function getByBlockId(int $idBlock): array
|
||||
{
|
||||
$result = Db::getInstance()->executeS(
|
||||
'SELECT `id_ws_customhtml_slide`, `title`, `description`, `extra_description`, `link`, `link_text`, `image`, `ordering`
|
||||
FROM `' . _DB_PREFIX_ . 'ws_customhtml_slide`
|
||||
WHERE `id_ws_customhtml` = ' . (int) $idBlock . '
|
||||
ORDER BY `ordering` ASC'
|
||||
);
|
||||
|
||||
return $result ?: [];
|
||||
}
|
||||
|
||||
public static function deleteByBlockId(int $idBlock): void
|
||||
{
|
||||
Db::getInstance()->delete('ws_customhtml_slide', '`id_ws_customhtml` = ' . (int) $idBlock);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user