我正在寻找在PhpStorm中打开最近关闭的文件的快捷方式.
我知道一些类似的快捷方式,但我正在寻找与Ctrl + Shift + T浏览器相同的命令...
我正在寻找类似的东西:
DB::table('users')->getNextGeneratedId();
Run Code Online (Sandbox Code Playgroud)
不
$user->save($data)
$getNextGeneratedId = $user->id;
Run Code Online (Sandbox Code Playgroud)
有人知道这很热吗?
我有模特:
protected $casts = [
'date' => 'date',
];
Run Code Online (Sandbox Code Playgroud)
laravel是否具有设置强制转换格式的能力,例如:
protected $casts = [
'date' => 'date_format:d/m/yyyy',
];
Run Code Online (Sandbox Code Playgroud)
?
EDITED
我试过这个:
在模型中:
protected $dateFormat = 'm/d/Y';
protected $dates = ['driver_expiration', 'created_at', 'updated_at', 'deleted_at'];
protected $casts = [
'driver_expiration' => 'date',
];
Run Code Online (Sandbox Code Playgroud)
我将日期(driver_expiration)保存为'01/012016'但日期已保存.
laravel文档:https://laravel.com/docs/5.1/eloquent-mutators 告诉我们$ dateFormat仅适用于时间戳('created_at','updated_at','deleted_at')
我收到客户遇到的许多错误的报告
Symfony的\分量\调试\异常\ FatalErrorException
最大执行时间超过30秒
我,我自己,无法在我的本地机器上或生产服务器上复制它.这个网址遍布整个网站,因此,我猜它是全球性的,就像一个造成这种情况的中间件.
我使用Sentry.io来收集数据,但异常跟踪只有1个条目指向Symfony基本代码中的某个代码,最常见的是:
第73行的vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php
第45行的vendor/symfony/finder/Iterator/DateRangeFilterIterator.php
第69行的vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php
显然,似乎存在与文件系统相关的东西,但由于没有跟踪,我无法看到在站点代码中查找错误的位置.我猜它是某种无限循环或泄漏,但没有任何痕迹可以看,并没有一致的方法来重现问题.
我应该如何寻找问题并进行调试?
我可以设置任何设置,还是可以使用/启用的工具?
我想要这样的东西:
env('APP_ENV');
setenv('APP_ENV', 'testing');
env('APP_ENV');
Run Code Online (Sandbox Code Playgroud)
输出 :
staging
testing
Run Code Online (Sandbox Code Playgroud)
我找到了一个答案How to Change Variables in the .env filedynamic in Laravel? 但这里.env是永久保存的,我不想永久保存。phpunit 是如何做到这一点的?因为我可以在 phpunit.xml 中放入以下内容:
...
<php>
<env name="APP_ENV" value="testing"/>
</php>
....
Run Code Online (Sandbox Code Playgroud)
env('APP_ENV') 给了我“测试”......
我有链接:
example.com/register#register
Run Code Online (Sandbox Code Playgroud)
如果验证失败,laravel将重定向到:
example.com/register
Run Code Online (Sandbox Code Playgroud)
带有验证错误的位,没有哈希网址部分。如何使用#重定向到完整网址?
我知道我可以使用:
Redirect::to(route('register') . '#credits')
Run Code Online (Sandbox Code Playgroud)
但我想要完整的解决方案,所以我:
return back();
Run Code Online (Sandbox Code Playgroud)
将使用#重定向。
也许我需要重写一些代码?
我有模特:
use seoTrait;
protected $fillable = [
'name', 'title', 'description'
];
Run Code Online (Sandbox Code Playgroud)
我在$ fillable中创建了需要"seoMeta"的特质"seoTrait".
现在我补充说:
protected $fillable = [
'name', 'title', 'description', 'seoMeta'
];
Run Code Online (Sandbox Code Playgroud)
但是有可能在特质"seoTrait"中添加一些东西给$ fillable吗?
我可以用这种方式获取not-bind查询:
\DB::enableQueryLog();
$items = OrderItem::where('name', '=', 'test')->get();
$log = \DB::getQueryLog();
print_r($log);
Run Code Online (Sandbox Code Playgroud)
输出是:
(
[0] => Array
(
[query] => select * from "order_items" where "order_items"."name" = ? and "order_items"."deleted_at" is null
[bindings] => Array
(
[0] => test
)
[time] => 0.07
)
)
Run Code Online (Sandbox Code Playgroud)
但我真正需要的是绑定查询,如下所示:
select * from "order_items" where "order_items"."name" = 'test' and "order_items"."deleted_at" is null
Run Code Online (Sandbox Code Playgroud)
我知道我可以用原始PHP做到这一点但是laravel核心有什么解决方案吗?
我可以使用以下代码获取命令中的参数:
$this->argument();
Run Code Online (Sandbox Code Playgroud)
但如何引起外界的争论呢?
如果我查看 argument() 函数的来源,我会看到:
public function argument($key = null)
{
if (is_null($key)) {
return $this->input->getArguments();
}
return $this->input->getArgument($key);
}
Run Code Online (Sandbox Code Playgroud)
我想检测命令“php artisan migrate:refresh --seed”何时运行,因为我希望模型中的某些代码在本地主机环境中运行,但在播种期间不在本地主机环境中运行...
我想要路线:
Route::get('/{slug}/{slug-2}/{slug-3}/../{slug-n}', ['as' => 'slug', 'uses' => 'SlugController@slug']);
Run Code Online (Sandbox Code Playgroud)
如何用laravel定义它甚至可能?
laravel ×9
php ×7
laravel-5 ×3
laravel-5.1 ×2
laravel-5.2 ×2
casting ×1
date ×1
debugging ×1
laravel-5.5 ×1
phpstorm ×1
symfony ×1
timeout ×1
webstorm ×1