更换model目录
This commit is contained in:
40
app/Models/Api/Follow/FollowHistoryModel.php
Normal file
40
app/Models/Api/Follow/FollowHistoryModel.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user