我已经nginx
在环境中安装了服务器Amazon Linux 2
。在创建弹性负载均衡器期间,我创建了 Amazon 的免费证书。现在,我想通过https
(端口443
)访问我的服务器。我如何SSL
在 中配置此证书nginx.conf
?
nginx.conf 中的 SSL 配置现已注释。我看到它包含两行,例如:
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
Run Code Online (Sandbox Code Playgroud)
现在,亚马逊证书和密钥文件的位置在哪里?
我@admin ... @endadmin
在 中创建了一个自定义刀片指令AppServiceProvider
。但该指令正在被缓存。php artisan view:clear
这就是为什么我每次新登录后都必须运行命令的原因。在不影响性能的情况下使用自定义刀片指令的最佳方法是什么?
boot
这是方法中的逻辑AppServiceProvider
Blade::directive('admin', function () {
$isAuth = 'false';
if (Auth::user() && Auth::user()->role_id == 3) {
$isAuth = 'true';
}
return "<?php if ($isAuth): ?>";
});
Blade::directive('endadmin', function () {
return "<?php endif; ?>";
});
Run Code Online (Sandbox Code Playgroud) 我正在做一个 Laravel-5.4 项目。我有三个表users
,articles
并且comments
在我的数据库中。
articles
表格截图:
comments
表格截图:
Article
模型:
class Article extends Model
{
public function comments() {
return $this->morphMany('App\Comment', 'commentable');
}
}
Run Code Online (Sandbox Code Playgroud)
Comment
模型:
class Comment extends Model
{
public function commentable() {
return $this->morphTo();
}
}
Run Code Online (Sandbox Code Playgroud)
ArticleController
包含以下方法:
public function showComments() {
return Article::find(1)->comments;
}
Run Code Online (Sandbox Code Playgroud)
以上showComments()
方法返回[]
(空数组)。我想返回这篇文章的所有评论id=1
。问题是什么?
我想找到groupBy
Laravel 中的最后几行。我有如下表:
id name ad_id
1 a 1
2 b 2
3 a 2
4 c 1
Run Code Online (Sandbox Code Playgroud)
ad_id
我希望结果按如下方式分组:
id name ad_id
3 a 2
4 c 1
Run Code Online (Sandbox Code Playgroud)
我当前的查询:
MyTable::groupBy('ad_id')->orderBy('id', 'desc')->get();
Run Code Online (Sandbox Code Playgroud)
它返回前两行。那么,我的雄辩询问应该是什么?
我已经按照本教程实现了 Laravel-5.8 电子邮件验证:https ://laravel.com/docs/5.8/verification 。我试图保护几条路线免受电子邮件未经验证的用户的影响,如下所示:
Route::group(['middleware' => ['verified']], function () {
Route::get('/dashboard', 'DashboardController@dashboard')->name('dashboard');
Route::get('/backend', 'DashboardController@backend')->name('backend');
});
Run Code Online (Sandbox Code Playgroud)
但是我可以在dashboard
不验证我的电子邮件地址的情况下访问。
如何在不验证电子邮件的情况下阻止此访问?