1
0
Files
helper/application/common/service/Advert.php
2020-08-06 14:58:51 +08:00

79 lines
2.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\service;
use app\common\model\Advert as AdvertModel;
use app\common\validate\Advert as AdvertValidate;
class Advert extends _Init
{
public static function add($data)
{
$validate = new AdvertValidate();
if (!$validate->check($data)) {
return $$validate->getError();
}
if (AdvertModel::create($data)) {
return true;
} else {
return '添加失败';
}
}
public static function edit($data)
{
$validate = new AdvertValidate();
if (!$validate->check($data)) {
return $$validate->getError();
}
if (AdvertModel::update($data)) {
return true;
} else {
return '编辑失败';
}
}
public static function del($id)
{
$info = AdvertModel::get($id);
if (!$info) {
return $this->error('数据不存在');
} elseif ($info->save(['status' => -1])) {
return true;
} else {
return '删除失败';
}
}
/**
* [status description]
* @param [type] $id [description]
* @param [type] $status [description]
* @param [type] $type [description]
* @return [type] [description]
*/
public static function status($id, $status, $type)
{
$info = AdvertModel::get($id);
if (!$info) {
return $this->error('数据不存在');
} elseif ($info->save([$type => $status])) {
Logs::write('修改状态', [$type => $status]);
return true;
} else {
return '设置失败';
}
}
}