我对传入的POST请求使用以下日期验证.
'trep_txn_date' => 'date_format:"Y-m-d H:i:s.u"'
Run Code Online (Sandbox Code Playgroud)
这只允许这种日期,即2012-01-21 15:59:44.8
我也想允许没有TIME的日期,例如2012-01-21,当发送到mysql db时会自动存储为2012-01-21 00:00:00.0
有没有办法可以使用Laravel现有的验证规则来实现这一点.有没有办法在date_format规则中定义多种格式,如下所示.
'trep_txn_date' => 'date_format:"Y-m-d H:i:s.u","Y-m-d"' //btw this didn't work.
Run Code Online (Sandbox Code Playgroud)
谢谢,
ķ
将php版本降级到7.1并将其默认设置为最新的Homestead 7有哪些步骤,Homestead 7默认配置为php版本7.2.
我的宅基地上有很多开发站点我希望一切都能在7.1上运行,如果我需要7.2那么我将在我的家园yaml中使用以下内容
sites:
- map: homestead.test
to: /home/vagrant/Code/homestead/public
php: "7.2"
Run Code Online (Sandbox Code Playgroud) 我在ItemsController中有一个myitems($ filter)方法,用于加载myitems.blade视图.
视图将项目列表作为标签和文本框以获取项目数量($项目从myitems方法传递到myitems视图,并且还有一个模型表单绑定项目模型)
我有一个选择框,有选项1.全部,2.过期和3.新
当我更改选择时,我想从控制器获取新的$ items并使用新项列表重新创建表单.
我正在使用jquery来警告选择已更改.但我无法弄清楚如何从ajax调用myitems($ filter)并重定向以创建items.blade页面.
我添加了以下内容 Console/Kernal
protected function schedule(Schedule $schedule)
{
$schedule->command('queue:work')
->everyMinute()
->appendOutputTo($filePath);
}
Run Code Online (Sandbox Code Playgroud)
然后在cmd提示符下我运行了以下artisan命令来运行计划任务但我收到以下错误
php artisan schedule:run
Run Code Online (Sandbox Code Playgroud)
错误:
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined method Illuminate\Console\Scheduling\Event::appendOutputTo()
Run Code Online (Sandbox Code Playgroud)
当我使用时,->sendOutputTo($filename)它工作正常,当然它不会附加,但覆盖文件.
谢谢,
ķ
我能够使用 Laravel Storage 和 FileSystem 类成功上传文件。
我的问题是我想通过其内容唯一地标识文件。
我想当我将文件保存在服务器上时,我用内容的哈希重命名上传的文件。
问题是有没有办法获取文件内容的哈希值。另一个复杂性是它是一个 excel 文件。
注意:我尝试使用 md5_file 来使用文件哈希,但是对于 xlsx 文件,即使我保存文件而不进行单一更改,md5_file 也不相同。
谢谢,K
我想<thead>在datatable中添加一个包含我的过滤器的附加内容.
我可以使用以下脚本执行此操作.(为了这个工作我应该在dom中定义)
var tableid = $('#dataTableBuilder');
num_columns = tableid.find('thead > tr:first > th').length;
tableid.find('thead > tr:first').before('<tr id="filter-row"></tr>');
var filterrow = tableid.find('#filter-row');
while (num_columns-- > 0) filterrow.append('<th></th>');
Run Code Online (Sandbox Code Playgroud)
问题是我不想看DOM来计算添加那么多列的列数<th>.(原因是我使用Yajra Datatables HtmlBuilder生成我的表,我不知道前面的列数和只添加的表代码<table id='xxxxxx'></table>)
我希望能够理解这个问题,我只需要知道如何使用数据表来计算列数.
我试过myDataTable.fnSettings().aoColumns.length但它说"fnSettings不是一个函数"它看起来像是在1.10被删除了,有没有替代它?
我正在使用barryvdh / laravel-snappy生成pdf文件。我有两个图像文件1. yourlogohere.png在public / image /文件夹中,并且2. logo2.png在public以外的文件夹中,即storage / app / logo,要获取此文件,我定义了一条路线(www.example.org /logo/logo.png),然后使用以下代码进行访问。
public function logo($filename)
{
$file = Storage::disk('local_logo')->get($filename);
$mime = 'image/png';
return (new Response($file, 200))->header('Content-Type', $mime);
}
Run Code Online (Sandbox Code Playgroud)
问题:
当我使用以下代码从包含第一个文件的html生成pdf时,pdf包含yourlogohere.png图像
$snappy = App::make('snappy.pdf');
$html='<img src="http://www.example.org/images/yourlogohere.png" class="img-responsive" alt="Your Logo Here">';
$snappy->generateFromHtml($html, $path,[],$overwrite = true);
Run Code Online (Sandbox Code Playgroud)
但是当我对第二个文件执行完全相同的操作时,pdf不会渲染图像(当我http://www.example.org/logo/logo2.png在浏览器中打开链接时,会得到图像)。我想念什么?
$snappy = App::make('snappy.pdf');
$html='<img src="http://www.example.org/logo/logo2.png" class="img-responsive" alt="Your Logo Here">';
$snappy->generateFromHtml($html, $path,[],$overwrite = true);
Run Code Online (Sandbox Code Playgroud)
谢谢,
ķ
laravel ×5
ajax ×1
date-format ×1
file ×1
hash ×1
homestead ×1
laravel-5 ×1
laravel-5.1 ×1
php ×1
wkhtmltopdf ×1