本文整理汇总了PHP中app\Board::bans方法的典型用法代码示例。如果您正苦于以下问题:PHP Board::bans方法的具体用法?PHP Board::bans怎么用?PHP Board::bans使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Board
的用法示例。
在下文中一共展示了Board::bans方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addRobotBan
/**
* Automatically adds a R9K ban to the specified board.
*
* @static
* @param \App\Board $board The board the ban is to be added in.
* @param binary|string|null $ip Optional. The IP to ban. Defaults to client IP.
* @return static
*/
public static function addRobotBan(Board $board, $ip = null)
{
$ip = new IP($ip);
// Default time is 2 seconds.
$time = 2;
// Pull the ban that expires the latest.
$ban = $board->bans()->whereIpInBan($ip)->whereRobot()->orderBy('expires_at', 'desc')->first();
if ($ban instanceof static) {
if (!$ban->isExpired()) {
return $ban;
}
$time = $ban->created_at->diffInSeconds($ban->expires_at) * 2;
}
return static::create(['ban_ip_start' => $ip, 'ban_ip_end' => $ip, 'expires_at' => Carbon::now()->addSeconds($time), 'board_uri' => $board->board_uri, 'is_robot' => true, 'justification' => trans('validation.custom.unoriginal_content')]);
}