雄辩模型事件updating和updated之间有什么区别?
我的猜测是updating在模型更新之前和updated模型更新之后触发。这对我来说意味着updating当我更新模型时应该总是触发 - 即使没有值实际改变。然而,这两个事件似乎仅在事件实际更改了数据库中的值时才会触发。那有什么区别呢?
我创建了一个 Laravel 应用程序,我在本地使用 homestead 开发该应用程序,并在生产服务器上在线运行。
我只有 SSL 证书,www.mydomain.com但没有mydomain.com,这就是为什么我强制htaccess重定向到https://www.*****. 我通过更改文件来做到这一点,如/sf/answers/979824891/myproject/public/.htaccess中所述
重定向在我的生产服务器上工作正常,但在我的本地环境 homestead 上没有发生重定向。为什么在我的本地环境中重定向被忽略?
这是完整的.htaccess文件:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain …Run Code Online (Sandbox Code Playgroud) 我想在 TinyMCE 编辑器中上传图像。我在文档中找到了相关说明。
这些是我的 Javascript 设置:
tinymce.init({
selector: '#about',
images_upload_url: '/home/profile/about/img',
});
tinymce.activeEditor.uploadImages(function(success) {
$.post('/home/profile/about/img', tinymce.activeEditor.getContent()).done(function() {
console.log("Uploaded images and posted content as an ajax request.");
});
});
Run Code Online (Sandbox Code Playgroud)
我创建了以下路线来检查一切是否设置正确
Route::post('/home/profile/about/img', function(){
return json_encode(['location' => '/storage/app/public/pictures/bestAvatar.png' ]);
});
Run Code Online (Sandbox Code Playgroud)
我希望当我上传图像时不会上传任何图像并显示图像bestAvatar.png- 但是我收到一个错误:
我错过了什么吗?是否可能是因为 tinymce ajax 调用中没有默认的 csrf 令牌?
在Laravel 5.6的文档中,它在此声明可以配置他的日志记录通道config/logging.php.我已经从Larvel 5.5更新到Laravel 5.6但我找不到这个配置文件.
我是否需要为这个或类似的东西打电话给一个特殊的工匠命令?
在 Voyager 项目中,它们允许您通过回调函数修改 TinyMCE :
function tinymce_init_callback(editor)
{
//...
}
Run Code Online (Sandbox Code Playgroud)
此处列出了编辑器的方法。
我知道通常会在 init 上列出插件:
tinymce.init({
plugins: [
'image textcolor'
],
Run Code Online (Sandbox Code Playgroud)
但是,它可以添加一个插件像image与编辑器的初始化后的对象?我在文档中找不到这样的功能。
当我想在 GitHub 上对 Laravel 包发出拉取请求时,我会按以下方式进行操作:
我觉得这有点麻烦——这真的是正确的做法吗?
例如,如果我想为voyager 包创建 PR ,我必须对步骤 1. 和 2 执行以下命令。
>laravel new create-pr
>cd create-pr
>composer require tcg/voyager
>php artisan voyager:install
Run Code Online (Sandbox Code Playgroud)
然后删除该文件夹tcg/voyager并将分叉克隆为新文件夹tcg/voyager。
如果我跳过composer require tcg/voyager并直接将分叉克隆到tcg/voyager我无法安装该软件包,因为
我将约束急切加载与匿名函数一起使用:
$users = App\User::with(['posts' => function ($query) {
$query->where('title', 'like', '%first%');
}])->get();
Run Code Online (Sandbox Code Playgroud)
现在我想用类函数替换匿名函数。根据PHP:我发现如何使用类函数作为回调
实例化对象的方法作为数组传递,该数组包含索引 0 处的对象和索引 1 处的方法名称。
因此我预计以下内容会起作用:
public function start()
{
$users = App\User::with(['posts' => [$this, 'addRestrain']])->get();
// ...
}
private function addRestrain($query)
{
$query->where('title', 'like', '%first%');
}
Run Code Online (Sandbox Code Playgroud)
然而,Laravel 检测到传递的参数不是闭包,而是数组:
“类型错误:传递给 Illuminate\Database\Eloquent\Builder::eagerLoadRelation() 的参数 3 必须是 Closure 的实例,给定数组,在
这是否意味着不能使用类函数来实现急切加载约束?
我更新到 Laravel 5.6,我想使用类中的新locale方法Mailable。
我创建了一个可邮寄的类
php artisan make:mail Test --markdown="emails.test"
Run Code Online (Sandbox Code Playgroud)
这是我的刀片文件:
@component('mail::message')
@lang('list.test')
@endcomponent
Run Code Online (Sandbox Code Playgroud)
如果我发邮件
$test = new \App\Mail\Test();
$test->locale('de');
\Mail::to('myemail@test.com')->send($test);
Run Code Online (Sandbox Code Playgroud)
然后邮件没有使用我的语言环境文件 resources/lang/de/list.php
<?php
return [ 'test' => 'Dies ist ein Test'];
Run Code Online (Sandbox Code Playgroud)
这是为什么?
假设我在一个隐藏的div 中有一个select2框,如下所示:
<form >
<div id="agent007">
<select name="slimy" id="slimy">
<option>Good</option>
<option>Bad</option>
</select>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
选择框全角且div隐藏的情况
select{
width:100%
}
div{
display:none;
}
Run Code Online (Sandbox Code Playgroud)
当我使div可见时,选择框没有全角。
$(document).ready(function(){
$('#slimy').select2();
$('#agent007').show();
});
Run Code Online (Sandbox Code Playgroud)
如何制作一个select2框全隐藏在不可见容器中全宽?
这是一个jFiddle