发布推送
This commit is contained in:
48
app/Models/Post/PostHistoryModel.php
Normal file
48
app/Models/Post/PostHistoryModel.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace App\Models\Post;
|
||||
|
||||
use App\Exceptions\ModelException;
|
||||
use App\Models\Base\BaseModel;
|
||||
|
||||
class PostHistoryModel extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_post_history';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'method',
|
||||
'oid',
|
||||
'uuid',
|
||||
'mid',
|
||||
'uid',
|
||||
'media',
|
||||
'content',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
const METHOD_ADD = 1;
|
||||
const METHOD_DEL = 2;
|
||||
const METHOD_EDIT = 4;
|
||||
const METHOD = [
|
||||
self::METHOD_ADD => '新增',
|
||||
self::METHOD_DEL => '删除',
|
||||
self::METHOD_EDIT => '编辑',
|
||||
];
|
||||
|
||||
/**
|
||||
* @throws ModelException
|
||||
*/
|
||||
function addPostHistory($method, $aItem): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|array|null
|
||||
{
|
||||
if(!in_array($method,self::METHOD)) throw new ModelException('addPostHistory method error');
|
||||
if(!isset($aItem['uuid'])) throw new ModelException('addPostHistory params error');
|
||||
$aItem['oid'] = $aItem['id'];
|
||||
unset($aItem['id']);
|
||||
$sDateTime = date('Y-m-d H:i:s');
|
||||
$aItem['created_at'] = $sDateTime;
|
||||
$aItem['method'] = $method;
|
||||
return $this->addItem($aItem);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user