草庐IT

php - Laravel 环境类型列表

我想知道Laravel默认支持哪些环境。我知道“生产”和“本地”有两个可用,但是没有其他的吗?如果是这样,它如何改变日志记录的行为。另一件事是我相信我声明一个自定义环境,它会导致任何意外行为吗?谢谢! 最佳答案 唯一对框架有意义的值是production、testing和local。当您的环境是生产时,这只会为一些artisan命令(例如迁移、播种)增加一点额外的保护。在production中时,必须使用--force选项运行这些命令。当您的环境正在测试时,这会使App::runningUnitTests()返回true。这用于在运

php - Laravel Cashier - $stripeToken 从哪里来?

documentationLaravelCashier上的内容非常模糊,并且遗漏了一些非常重要的细节,例如$stripeToken是什么以及它来自哪里?因此,为了创建一个新的订阅,我们这样做:$user->newSubscription('main','premium')->create($stripeToken);这是用户第一次订阅,那么$stripeToken究竟来自哪里?在文档中说:Thecreatemethod,whichacceptsaStripecreditcard/sourcetoken,willbeginthesubscriptionaswellasupdateyour

php - laravel 5.5 邮件通知不更新内容

token=$token;}/***Getthenotification'sdeliverychannels.**@parammixed$notifiable*@returnarray*/publicfunctionvia($notifiable){return['mail'];}/***Getthemailrepresentationofthenotification.**@parammixed$notifiable*@return\Illuminate\Notifications\Messages\MailMessage*/publicfunctiontoMail($notifia

php - Laravel 和 Page 中的路由问题找不到

我在弹出窗口中有联系表格,但是当我点击发送按钮时,我没有找到页面,而不是将我重定向到主页。这是我的路线Route::post('/contact_us','HomeController@contact_us')->name('contact_us');HomeController.php中的函数publicfunctioncontact_us(Request$request){$validator=Validator::make($request->all(),['name'=>'required','phone'=>'required','email'=>'required|emai

php - Laravel 5.8 - 如何将文件从存储目录移动到公共(public)目录?

我想将我的一个文件从Laravel的storage文件目录移动到laravel的public文件目录,而不更改我的文件系统配置。这可能吗? 最佳答案 是的,你可以用Storage::move来做和public_path()helper。Storage::move('old/file.jpg',public_path('new/file.jpg'));请注意,old/file.jpg是相对于your-project/storage/app的,因此您要移动的文件将位于your-project/storage/app/old/file.j

php - 将参数传递给 laravel 中的 Restful Controller

我刚刚开始在laravel4中实现restfulController。我不明白在使用这种路由方式时如何将参数传递给Controller​​中的函数。Controller:classMcControllerextendsBaseController{private$userColumns=array("stuffhere");publicfunctiongetIndex(){$apps=Apps::getAllApps()->get();$apps=$apps->toArray();returnView::make('mc')->nest('table','mc_child.table'

php - 在扩展 LaravelValidator 的自定义 Laravel Validator 类中进行依赖注入(inject)

我需要在扩展LaravelValidator的自定义LaravelValidator类中的某些验证方法中访问Db存储库。如何获取?我的类构造函数:page=$page;$this->element=$element;}[...]和我的验证器解析器(在Laravel文档中):如何让它发挥作用?谢谢 最佳答案 好的...我找到了解决方案。我的类构造函数:translator=$translator;$this->data=$data;$this->rules=$this->explodeRules($rules);$this->mess

php - Laravel MIME 验证

关于使用Laravel验证JavaScript文件的上传,我遇到了麻烦,验证规则是:'javascript_file'=>'required|mimes:js'据我所知这应该有效,因为Laravel使用mime_content_type()猜测文件的mime,但它没有通过,在使用application/javascriptmime类型的文件进行测试时给我一个mime类型错误编辑:dd($_FILES)给出["name"]=>string(7)"data.js"["type"]=>string(22)"application/javascript"["tmp_name"]=>string

php - Laravel:绑定(bind)到 IoC 容器

如果您将一个类绑定(bind)到IoC...App::bind('Thing',function(){returnnew\ThingOne;});然后,除非您调用App::make('Thing'),否则ThingOne对象永远不会被实例化。这是好事。但是,如果您尝试覆盖该绑定(bind):App::bind('Thing',function(){returnnew\ThingOne;});App::bind('Thing',function(){returnnew\ThingTwo;});App::bind('Thing',function(){returnnew\ThingThre

php - Laravel 5.1 - barryvdh/laravel-dompdf,PDF 文件下载不正常

我已经使用composer安装了'barryvdh/laravel-dompdf'并添加了这些行Barryvdh\DomPDF\ServiceProvider::class'PDF'=>Barryvdh\DomPDF\Facade::class到“config”文件夹中的“app.php”文件并创建PdfController,就像这样loadHTML('Test');return$pdf->stream('testfile')->header('Content-Type','application/pdf');}}现在代码工作正常,内容以pdf格式显示在浏览器中,但是当我下载此文件时,