add cms banners

This commit is contained in:
JaguarJack
2021-05-26 20:35:19 +08:00
parent 4b30123aa4
commit af8e6c3f5d
4 changed files with 150 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<?php
namespace catchAdmin\cms\model\events;
use catchAdmin\cms\model\Banners;
trait BannersEvent
{
/**
* 插入前
*
* @time 2021年05月21日
* @param Banners $model
* @return void
*/
public static function onBeforeInsert(Banners $model)
{
self::beforeChangeData($model);
}
/**
*
* @auth CatchAdmin
* @time 2021年05月22日
* @param Banners $model
* @return void
*/
public static function onBeforeUpdate(Banners $model)
{
self::beforeChangeData($model);
}
/**
* 插入前
*
* @auth CatchAdmin
* @time 2021年05月22日
* @param $model
* @return void
*/
protected static function beforeChangeData($model)
{
$data = $model->getData();
if (isset($data['category_id'])) {
$model->category_id = $model->category_id[count($model->category_id) - 1];
}
}
}