mirror of
https://github.com/Karaka-Management/oms-News.git
synced 2026-01-21 12:48:41 +00:00
79 lines
1.7 KiB
PHP
79 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Orange Management
|
|
*
|
|
* PHP Version 7.1
|
|
*
|
|
* @category TBD
|
|
* @package TBD
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 1.0
|
|
* @version 1.0.0
|
|
* @link http://orange-management.com
|
|
*/
|
|
declare(strict_types=1);
|
|
namespace Modules\News\Models;
|
|
|
|
use Modules\Admin\Models\AccountMapper;
|
|
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|
use phpOMS\DataStorage\Database\Query\Builder;
|
|
use phpOMS\DataStorage\Database\Query\Column;
|
|
use phpOMS\DataStorage\Database\RelationType;
|
|
|
|
class BadgeMapper extends DataMapperAbstract
|
|
{
|
|
|
|
/**
|
|
* Columns.
|
|
*
|
|
* @var array
|
|
* @since 1.0.0
|
|
*/
|
|
static protected $columns = [
|
|
'news_badge_id' => ['name' => 'news_badge_id', 'type' => 'int', 'internal' => 'id'],
|
|
'news_badge_title' => ['name' => 'news_badge_title', 'type' => 'string', 'internal' => 'title'],
|
|
];
|
|
|
|
/**
|
|
* Primary table.
|
|
*
|
|
* @var string
|
|
* @since 1.0.0
|
|
*/
|
|
protected static $table = 'news_badge';
|
|
|
|
/**
|
|
* Primary field name.
|
|
*
|
|
* @var string
|
|
* @since 1.0.0
|
|
*/
|
|
protected static $primaryField = 'news_badge_id';
|
|
|
|
/**
|
|
* Create object.
|
|
*
|
|
* @param mixed $obj Object
|
|
* @param int $relations Behavior for relations creation
|
|
*
|
|
* @return mixed
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function create($obj, int $relations = RelationType::ALL)
|
|
{
|
|
try {
|
|
$objId = parent::create($obj, $relations);
|
|
|
|
if($objId === null || !is_scalar($objId)) {
|
|
return $objId;
|
|
}
|
|
} catch (\Exception $e) {
|
|
return false;
|
|
}
|
|
|
|
return $objId;
|
|
}
|
|
|
|
}
|