更换model目录

This commit is contained in:
cano
2024-03-04 04:28:48 +08:00
parent f4f61a5f4c
commit bebbee4184
29 changed files with 90 additions and 146 deletions

View File

@ -0,0 +1,40 @@
<?php
namespace App\Models\Api\Follow;
use App\Exceptions\ModelException;
use App\Models\Api\Base\ApiBaseModel;
class FollowHistoryModel extends ApiBaseModel
{
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);
}
}