草庐IT

php - Laravel 5.5 在验证请求文件中使用自定义验证规则?

是否可以在验证请求文件中使用我的自定义验证规则?我想使用名为EmployeeMail的自定义规则这是请求文件的代码classCoachRequestextendsFormRequest{/***Determineiftheuserisauthorizedtomakethisrequest.**@returnbool*/publicfunctionauthorize(){returntrue;}/***Getthevalidationrulesthatapplytotherequest.**@returnarray*/publicfunctionrules(){$rules=[];if(

php - 如何在 Laravel 5.5 中禁用 filp/whoops 包而不删除它?

Laravel5.5应用程序。原来是5.3。我按照升级指南安装了filp/whoops包,但现在我想禁用它,因为我相信每当我遇到错误时它都会在我的Homestead机器上导致“内存不足”错误,这真的很烦人,因为我所看到的只是“允许的XXXXXX字节的内存大小耗尽”而不是真正的错误,这通常是某种解析错误。我不想更改PHP可用的内存,因为它与我的生产服务器上的内存相匹配。有什么简单的方法可以在不删除这个包的情况下禁用它吗? 最佳答案 尝试将以下方法添加到app/Exceptions/Handler.php中:protectedfunct

php - 如何获得两个时间间隔之间的星期五日期

我想从两个时间间隔中获取所有星期五的日期。我的框架是laravel。我的功能:publicfunctiongetFridaysInRange($dateFromString,$dateToString){$dateFrom=new\DateTime($dateFromString);$dateTo=new\DateTime($dateToString);$dates=[];if($dateFrom>$dateTo){return$dates;}if(1!=$dateFrom->format('N')){$dateFrom->modify('nextfriday');}while($da

php - 使用 Laravel 每月接收数据

我正在尝试创建一个显示每月数据的morrisJS折线图。所以我每个月都这样获取数据:$intakes=Intakes::whereYear('created_at','=',2018)->orWhere(function($query){$query->whereMonth('created_at','=',1)->whereMonth('created_at','=',2)->whereMonth('created_at','=',3)->whereMonth('created_at','=',4)->whereMonth('created_at','=',5)->whereMont

php - 当我尝试为我的数据库播种时出现错误

当我尝试使用faker在laravel5.4中播种我的数据库时出现错误useIlluminate\Database\Seeder;useapp\PostModell;classpostcarseederextendsSeeder{/***Runthedatabaseseeds.**@returnvoid*/publicfunctionrun(){//Let'struncateourexistingrecordstostartfromscratch.PostModell::truncate();$faker=\Faker\Factory::create();//Andnow,let'sc

php - Ajax 调用自动扩展 Laravel session ?

我有一个间隔运行的小JS脚本:functioncheckAuthState(){$.get('/session/check',function(response){console.log(response);});}setInterval(checkAuthState,10000);ControllerAction目前是一个虚拟Action:json(array('success'=>true));}我注意到,laravel_sessioncookie到期日期每次进行Ajax调用时都会自动延长-延长10秒(与JS间隔匹配).为什么会这样?我需要为session过期的情况添加一个处理程序

php - Laravel Echo 500 错误(广播/授权)?

祝你有美好的一天!我有一个问题:我设置了LaravelEcho&Pusher但出现了这个错误,不知道如何解决:(我检查了我的应用key、应用集群,但都是正确的。有人可以帮助我吗?app.jsconstapp=newVue({el:'#app',data:{messages:[]},methods:{addMessage(message){this.messages.push(message);axios.post('/messages',message).then(response=>{console.log(response);});}},created(){axios.get('/

php - Laravel:页面上带有 url 参数的表单

我有一个如下生成的路由,想在页面上放置一个表单:Route::get('suppliers/dashboards/{supplier}',['uses'=>'SuppliersDashInvoiceController@index'])->middleware('auth');Route::post('suppliers/dashboards/{supplier}',array('before'=>'csrf','uses'=>'SuppliersDashInvoiceController@iprocess'))->middleware('auth');但是当使用Formlaravel

php - 使用 Laravel 5.5 从 Bootstrap 3.3.7 迁移到 4.0

我已经开始使用Laravel5.5版本的元素,包括Bootstrapv.3.3.7。现在,我想测试一下我是否可以切换到新的4.0版本。我已经读过this但我不确定我元素中编写的所有代码是否都适用于新版本,而且我使用的是Laravel中包含的bootstrap-sass。我只需要运行:npmuninstallbootstrapnpminstallbootstrap要包含新版本的sass预处理器,还是我的代码会完全损坏?我愿意接受任何建议,因为我不知道这是否可行。 最佳答案 只需将"bootstrap":"^4.0.0"放入您的pack

php - cron 是在 php 中编写基于提醒的应用程序的最佳方式吗?

假设我有这样一个数据库。|task|time||---------------------------|---------------------------||Remindmetowaterplants|2018-02-18T19:32:10.486Z||EnglishTest|2018-10-8T09:30:00.000Z||MathTest|2018-10-8T10:30:00.000Z|而且我想在用户请求时(或者可能是一个小时前)向用户发送提醒通知,并在触发提醒通知的特定时间执行一些其他代码块。我正在考虑编写一个类似这样的cron作业*****php/laravel-proje