调用未定义函数 App\Http\Middleware\str_plural()
Call to undefined function App\Http\Middleware\str_plural()
我正在为我的应用程序制作用户禁止功能。但是,Laravel 6 显示未定义 function str_plural()
。我该如何解决这个问题?
public function handle($request, Closure $next)
{
if (auth()->check() && auth()->user()->banned_at && now()->lessThan(auth()->user()->banned_at)) {
$banned_days = now()->diffInDays(auth()->user()->banned_at);
auth()->logout();
if ($banned_days > 14) {
$message = 'Your account has been suspended. Please contact administrator.';
} else {
$message = 'Your account has been suspended for '.$banned_days.' '.str_plural('day',
$banned_days).'. Please contact administrator.';
}
return redirect()->route('login')->withMessage($message);
}
return $next($request);
}
应该是这个
use Illuminate\Support\Str;
Str::plural()
有关详细信息,您可以阅读 docs
我正在为我的应用程序制作用户禁止功能。但是,Laravel 6 显示未定义 function str_plural()
。我该如何解决这个问题?
public function handle($request, Closure $next)
{
if (auth()->check() && auth()->user()->banned_at && now()->lessThan(auth()->user()->banned_at)) {
$banned_days = now()->diffInDays(auth()->user()->banned_at);
auth()->logout();
if ($banned_days > 14) {
$message = 'Your account has been suspended. Please contact administrator.';
} else {
$message = 'Your account has been suspended for '.$banned_days.' '.str_plural('day',
$banned_days).'. Please contact administrator.';
}
return redirect()->route('login')->withMessage($message);
}
return $next($request);
}
应该是这个
use Illuminate\Support\Str;
Str::plural()
有关详细信息,您可以阅读 docs