Files
cycle_api/app/Models/Follow/FollowHistoryModel.php
2024-02-26 00:41:25 +08:00

41 lines
1.0 KiB
PHP

<?php
namespace App\Models\Follow;
use App\Exceptions\ModelException;
use App\Models\Base\BaseModel;
class FollowHistoryModel extends BaseModel
{
protected $table = 'customer_follow_history';
protected $primaryKey = 'id';
protected $fillable = [
'id',
'method',
'uid',
'follow_uid',
'created_at',
];
const METHOD_FOLLOW = 1;
const METHOD_UNFOLLOW = 2;
const METHOD = [
self::METHOD_FOLLOW => '关注',
self::METHOD_UNFOLLOW => '取关',
];
/**
* @throws ModelException
*/
function addFollowHistory($method, $uid, $follow_uid): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder|array|null
{
if(!in_array($method,self::METHOD)) throw new ModelException('method error');
$aItem['method'] = $method;
$aItem['uid'] = $uid;
$aItem['follow_uid'] = $follow_uid;
$sDateTime = date('Y-m-d H:i:s');
$aItem['created_at'] = $sDateTime;
return $this->addItem($aItem);
}
}