本文整理匯總了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')]);
}