草庐IT

laravel-environment

全部标签

php - Laravel 路线不适用于生产

我有一个Laravel5/angularJS应用程序(将Laravel作为apirest和angular作为前端)在我的本地环境中,一切都像魅力一样运作。但是当我上传到主机时,我只能访问索引页面,其他所有内容都会抛出404。在我的共享主机中,我有这样的文件系统。public_htmllaravel-backend(ithasapp,bootstrap,confi...etc,alllaravelapp)laravel-frontend(itwouldbelikethepublicfolderofthelaraveldefaultfilesystem).htaccess.htaccess

php - Laravel 在一个函数中加载多个 View

我只知道如何在单个Controller函数中调用多个View。我正在尝试:returnView::make('header');returnView::make('main');returnView::make('footer');任何建议。我如何称呼他们?提前致谢.. 最佳答案 您应该使用sections创建一个View为了便于重复使用。然后它允许您组成各个部分。layout.blade.php@yield('header')@yield('body')@yield('footer')combined.blade.php@exte

php - 为什么在 laravel blade 中条件 @if 不工作? (拉拉维尔 5.3)

如果我的代码是这样的:@foreach($categoriesas$category)@if($loop->first)$category_id=$category->id@endif@endforeach存在错误:Undefinedvariable:category_id(View:C:\xampp\htdocs\myshop\resources\views\front.blade.php)如果我的代码是这样的:@foreach($categoriesas$category)@phpif($loop->first)$category_id=$category->id@endphp@e

php - 在 Laravel 5.4 中从迁移中删除列

我使用像这样的迁移创建了一个表:Schema::create('listings',function(Blueprint$table){$table->increments('id');$table->decimal('original_price',10,2);$table->decimal('discouted_price',10,2);$table->integer('city_id')->index()->unsigned()->nullable();$table->foreign('city_id')->references('id')->on('cities');$tabl

php - 路由如何在 PHP laravel 中工作?

我刚开始玩Laravel框架,我看到了这个:Route::get('foo',function(){return'HelloWorld';});谁能解释一下这是什么?我的意思是,我知道什么是get。但是为什么我们先放'foo'然后放闭包呢?另外,我真正从哪里获得信息? 最佳答案 首先我们声明Route的Facade,想像一个使用Route类的捷径。然后我们选择路由的方法,可以是:Route::get($uri,$callback);//getRoute::post($uri,$callback);//postRoute::put($

php - Laravel:如何在 Controller 方法执行后重定向

web.php:Route::post('caption/{id}/delete','DetailController@deleteCaption');DetailController.php:publicfunctiondeleteCaption(Request$request,$id){$caption=Caption::findOrFail($id);$caption->delete();//doesn'tdeletepermanentlyreturnresponse(204);}admin.blade.php:id}}'>{{$caption->content}}id}}/de

php - Laravel 授权中间件 : Class can does not exist

我正在尝试通过中间件保护路由describedinthedoc当我点击url时,我得到:ReflectionExceptioninContainer.phpline749:Classcandoesnotexist这是来自routes.php的相关部分:Route::get('{user}/profile/edit/{type?}',['as'=>'edit','uses'=>'User\UserController@edit','middleware'=>['can:edit-user,user'],]);AuthServiceProvider.php:publicfunctionbo

php - Laravel - diffForHumans 德语

我正在尝试在laravel5.2中使用德语的Carbon的diffForHumans()显示created_at属性。created_at在数据库中存储为:2017-03-2917:31:52模型protected$dates=['created_at','updated_at'];publicstaticfunctiongetCreatedAtAttribute($value){Carbon::setLocale('de');returnCarbon::parse($value,'Europe/Berlin')->diffForHumans();}dd($value);返回"2017

php - LARAVEL - 显示存储文件夹中的图像

我是Laravel的新手,想知道是否有人可以通过简单的图片上传来帮助我。我有一个表单,允许用户在此过程中创建个人资料并上传个人资料和头像。这一切都很完美。这是来self的Controller的代码:if(request()->hasFile('avatar')){$file=request()->file('avatar');$file->storeAs('avatars/'.auth()->id(),'avatar.jpg');}图片保存在storage/app/avatars/USER-ID/avatar.jpg我不确定如何显示此文件夹中的图像。我一直在寻找解决方案,但我无法使用p

php - 通过 AWS EC2 上的 cron 安排 Laravel 5 - 命令未运行

问题:我有一个Laravel5.4artisan任务,我需要通过cron运行-但尽管命令和调度程序(显然)设置正确,但它没有完成。这是Laravel、php、apache、linux还是crontab问题?最好的诊断方法是什么?背景在默认(亚马逊AMI)EC2实例上,artisan命令被正确定义并在通过以下方式调用时从项目目录(/var/www/html/myproject/)完美运行:phpartisanmycommand:option1我已将其添加到app/Console/Kernel.php中,如下所示:protectedfunctionschedule(Schedule$sch