我目前正在使用我的Laravel应用程序并防止垃圾邮件我决定只有活跃用户才能登录.我正在使用Laravel的登录系统,就像在Laravel的官方网站教程中一样,这是我的表单操作:
<form class="form-horizontal" role="form" method="POST" action="{{ url('/auth/login') }}">
Run Code Online (Sandbox Code Playgroud)
这完全正常,但我想检查用户的活动,如果不活动,它将被重定向到激活页面,否则它将登录.有没有一种简单的方法可以做到这一点,还是我有义务制作新的控制器,路线和更多的验证?谢谢.
编辑:忘记提及我的数据库中有一个"活动"列.
我正在使用带有docker容器的gitlab-ci-multi-runner.一切都很顺利,但是docker容器没有保留composer缓存,所以在每次运行中composer一次又一次地下载依赖关系,这需要花费很多时间.有没有办法配置gitlab-ci-runnerdocker容器来保持composer缓存或在保存缓存的每次运行中挂载卷composer?
我正在尝试在视图页面中将字符串转换为小写(index.blade.php)
以下是我想要实现的目标.
<img src="images/teamnamesml.jpg logo">
Run Code Online (Sandbox Code Playgroud)
这是我的尝试
<img src="images/{{ Str::lower($matchup->visitorTeam) }}sml.jpg">
Run Code Online (Sandbox Code Playgroud)
我收到这个错误
FatalErrorException in ed1bb29e73e623d0f837c841ed066275 line 71:
Class 'Str' not found
Run Code Online (Sandbox Code Playgroud)
我是否必须将类导入Illuminate\Support\Str特定文件?
所以,我有一个页面上有一个带有"Create"值的按钮.当我单击"创建"按钮而不填写任何字段时,它会验证表单并在同一页面上显示错误消息.当我在浏览器中这样做时,它工作正常,但当我这样做时phpunit,它有意想不到的结果,我不知道为什么.
这是我的集成测试:
public function testCreateValidation()
{
$this->visit(route('patients.indexes.create', $this->patient->id));
$this->press('Create');
$this->seePageIs(route('patients.indexes.create', $this->patient->id));
}
Run Code Online (Sandbox Code Playgroud)
这就是结果:
There was 1 failure:
1) Tests\Integration\IndexControllerTest::testCreateValidation
Did not land on expected page [http://localhost/patients/69/indexes/create].
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'http://localhost/patients/69/indexes/create'
+'http://localhost/patients'
/vagrant/vendor/laravel/framework/src/Illuminate/Foundation/Testing/InteractsWithPages.php:141
/vagrant/tests/Integration/IndexControllerTest.php:51
Run Code Online (Sandbox Code Playgroud)
我不明白为什么它被重定向到patients页面.
以下是create正在测试的Laravel 方法:
public function create($id)
{
$index = $this->indexes->newInstance();
$patient = $this->patients->findOrFail($id);
return view('patient.index.create', ['index' => $index, 'patient' => $patient]);
}
Run Code Online (Sandbox Code Playgroud)
以下是该create视图的相关部分:
<?= Form::open(['route' => array('patients.indexes.store', $patient->id), 'class' …Run Code Online (Sandbox Code Playgroud) 我刚刚安装了Laravel 5.3,这是一个全新的安装,在查看了Docs后我设置了我的Gulpfile如下:
elixir((mix) => {
mix.sass('app.scss')
.webpack('app.js')
.version(['css/app.css', 'js/app.js'])
.browserSync({
proxy: 'subdomain.mydomain.dev'
});
});
Run Code Online (Sandbox Code Playgroud)
出于某种原因,我每次运行gulp watch它都会启动浏览器localhost:3000
我究竟做错了什么?如果我设置地址完全相同,是不是应该将BrowserSync指向我的Mamp Vhost?
我可以使用HTTPS设置在我的本地环境中运行laravel-echo-server.但是,似乎我的生产服务器(基于Forge)存在问题:
Client cannot be authenticated, got HTTP status 405
Run Code Online (Sandbox Code Playgroud)
我能够通过HTTPS在本地测试私有通道,它工作正常,所以看起来它不是一个配置问题.
我应该提一下,我正在使用Laravel Passport,并且导致此错误的请求被抛出在常规auth中间件之外的页面上.
只是为了确保它不是我的身份验证方法,我在通道配置中返回'true':
Broadcast::channel('App.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
Broadcast::channel('channelReceiveLiveData.{id}', function ($user, $id) {
return true;
});
Broadcast::channel('channelReceiveTestState.{id}', function ($id) {
return true;
});
Run Code Online (Sandbox Code Playgroud)
以下是侦听私有通道的echo侦听器的版本:
Echo.private('channelReceiveLiveData.' + this.$route.params.testID)
.listen('liveDataTrigger', (e) => {
if (!that.state.hasPulledInitialData) {
console.log('Receiving data before initial pull done');
}
Run Code Online (Sandbox Code Playgroud)
我的laravel-echo-server.json文件:
"authHost": "https://app.test.com",
"authEndpoint": "/broadcasting/auth",
"clients": [
{
"appId": "....",
"key": "...."
}
],
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": { …Run Code Online (Sandbox Code Playgroud) 当我以管理员身份运行Internet Explorer时,我看到了对window.open()的调用的不同行为.我无法在jsfiddle/codepen等sanboxed iframe环境中重现它,但我会尽力在这里解释这个问题.
在IE中,没有以管理员身份运行,当我按下"清空"按钮时,它会调用window.open("",windowname,...)并出现一个新的空白窗口.接下来,我按下"Full"按钮,它会调用window.open(" http://www.google.com ",windowname,..)以及旧的空白窗口设置为Google的内容.
在IE中,以管理员身份运行时,不会覆盖初始空白窗口.相反,空白窗口旁边会出现一个带有Google的新窗口.
我在下面提供了我的测试代码.我不确定它在iframe中的事实是否相关,但我包括它以防万一
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<iframe src="http://127.0.0.1:8888/">
</iframe>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
来自http://127.0.0.1:8888/的来源看起来像
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var windowname = "TESTWINDOW";
var features = "menubar=no, location=no, resizable=yes, status=yes, width=500, height=500";
function doEmpty(e) {
window.open("", windowname, features);
}
function doFull(e) {
window.open("http://www.google.com", windowname, features);
}
</script>
<style>
body {
width: 1000px;
height: 1000px;
}
</style>
</head>
<body>
<button onclick="doEmpty()">Empty</button>
<button onclick="doFull()">Full</button>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我正在尝试拥有一个管理子域名(像这样)
Route::group(['domain' => 'admin.localhost'], function () {
Route::get('/', function () {
return view('welcome');
});
});
Run Code Online (Sandbox Code Playgroud)
但是admin.localhost就像localhost一样.我该如何正确地做到这一点?
我在OSX上使用Laravel 5.1和MAMP
我一直在努力寻找一个正则表达式,它将在"CI/CD管道"页面的"测试覆盖率解析"输入中起作用.示例显示不一致的示例没有帮助,即一些转义括号和其他不符合,百分比符号相同,一些捕获显式结果$1等等.无论如何,这是我的文本 - 什么是正则表达式?
CI徽章:

Run Code Online (Sandbox Code Playgroud)
输出文字:
Unit test coverage:
10.01% blocks
10.01% lines
Run Code Online (Sandbox Code Playgroud)
尝试到目前为止:(添加斜线只是为了代表前面的空间或正则表达式)
/ \(\d+\.\d+\%\) blocks/
/ (\d+\.\d+\%) blocks/
/ (\d+\.\d+%) blocks/
/ (\d+\.\d+)% blocks/
Run Code Online (Sandbox Code Playgroud) 我有这段代码,我认为会永远记住缓存:
$setting = \Cache::remember('website_description', 0, function() {
return App\Models\Setting::where('name', 'website_description')->first();
});
Run Code Online (Sandbox Code Playgroud)
但它根本不记得,有人告诉我,传递0记住功能会让它永远记住.由于这不起作用,我可以将项目永远放在缓存中吗?
laravel ×7
laravel-5 ×6
php ×5
gitlab ×2
account ×1
browser-sync ×1
composer-php ×1
docker ×1
gitlab-ci ×1
html ×1
iframe ×1
javascript ×1
laravel-5.1 ×1
laravel-echo ×1
login ×1
phpunit ×1
subdomain ×1
unit-testing ×1