add cms banners
This commit is contained in:
49
catch/cms/model/events/BannersEvent.php
Normal file
49
catch/cms/model/events/BannersEvent.php
Normal 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];
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user