jjzjj

php - 在 view-file.blade.php 中找不到类 ' Form'

我正在尝试在我的View文件中呈现一个文本输入字段。我不断收到此错误:“在view-file.blade.php中找不到类‘表单’”模板:@extends('layouts.app')@section('content')New{{Form::open()}}{{ Form::text('my-name')}}{{Form::close()}}@endsectionComposer.json"require":{"php":">=7.0.0","fideloper/proxy":"~3.3","laravel/framework":"5.5.*","laravel/tinker":"~

php - laravel blade @include 不工作

我正在尝试使用blade语法将文件包含在我的主页中:-@foreach($dataas$articles)@include(app_path().$articles->path)@endforeach这是行不通的。错误说:-View[/var/www/blogproject/project/app/pages/articles/first-post.php]notfound我什至尝试只包括第一页:-@include(app_path().'/pages/articles/first-post.php')但是正常的phpinclude工作正常:-请帮忙 最佳答

php - Laravel 5.5 使用参数从 Blade View 调用 Controller 函数

我有一个产品slider,我正在尝试找出每种产品的最低价格。所以我首先尝试从Controller成功调用函数并传递产品的id并将其打印出来。blade.php@phpuseApp\Http\Controllers\ServiceProvider;echoServiceProvider::getLowestPrice($product_cat->id);@endphp路线Route::post('/getLowestPrice/{id}','ServiceProvider@getLowestPrice');Controller我得到一个错误Parseerror:syntaxerror,u

php - 在 Laravel Blade 模板中循环嵌套数组

我有以下代码:@foreach($data['daily']as$date=>$dailyData){{$date}}@foreach($dailyDataas$key=>$value){{$value}}{{$data['another_index'][$date][$key]}}@endforeach@endforeach这给我返回一个错误[ErrorException]Undefinedindex:date代码执行时。实际上,我在another_index中有值,我可以打印它。在此先感谢您的帮助。[another_index]=>Array([2016-03-15]=>Array

php - Laravel - 在 Blade 中加载更多结果时如何避免 N+1 问题?

我正在构建一个包含提交内容的网站,这些提交内容包含评论。这些评论的结构很像reddit的。这是一张供引用的图片:这些评论有很多关系(授权用户是否保存/赞成/反对评论,评论是否有child,谁创建了评论)。因此,为了避免一堆不必要的服务器查询,我急于加载这些关系。$comments=Comment::with(['children','owner','savedComments','votes'])->where('submission_id',$submission->id)->where('parent_id',NULL)->orderBy('removed','asc')->ord

php - 我怎样才能理顺 Laravel blade @extends 的执行顺序?

在myattemptstofindawaytopassavariablebyreferencetoablade@include,我构建了一个简单的测试用例,它也证明了模板的执行顺序非常不稳定。有没有办法在执行顺序很重要(特别是关于部分)的情况下使用带有变量的Blade模板?测试用例:testLayout.blade.php{{"thisisthelayout:".++$tabindex.""}}@include('testInclude'){{"thisisthelayoutafterinclude:".++$tabindex.""}}@include('testInclude',ar

php - 使用 Blade 转义字符串,渲染 HTML

我有一个$text变量,其中包含一些文本和HTML代码。我想呈现它的HTML,但仍要确保对字符串的其余部分进行转义。$text='Exampletextwithimage.Moretext...'//ThiswillrendertheHTMLbutwillNOTescapethestring{!!$text!!}//Thiswillescapeanddisplaythevariableasrawstring,withnoHTMLrendering{{$text}}在Laravel5中,有没有办法在允许HTML的情况下使用Blade转义字符串? 最佳答案

php - Laravel 5 : How can I pass a variable from a controller method to app. Blade .php?

我在布局文件app.blade.php中显示了一个变量。该变量在我的全局“ViewComposer”中定义了一个默认值。我需要从Controller方法中覆盖该值,我该怎么做? 最佳答案 这是一个棘手的问题。问题是View编写器在Controller返回View后被触发。但是,如果已设置该值,您可以在View编辑器中检查:publicfunctioncompose(View$view){if(!$view->offsetExists('foo')){$view->with('foo','default');}}当您想“覆盖”Cont

php - Laravel Blade View - undefined variable : errors

当访问我的laravel应用程序的登录页面时,我得到一个Undefinedvariable:errors(View:D:\PhpstormProjects\laravel\resources\views\login.blade.php)错误。根据http://laravel.com/docs/master/validation#error-messages-and-views,$errors应该总是自动设置:So,itisimportanttonotethatan$errorsvariablewillalwaysbeavailableinallofyourviews,oneveryre

php - 循环 PHP 嵌套数组 - 将值提取到 Blade Views (Laravel)

我知道有很多关于这个主题的问题,但没有一个能完全解决这个问题(据我所知)。我在Laravel项目中有一个PHP数组(仅供引用,通过Guzzle响应返回)。PHP数组$users=array(2){["error"]=>bool(false)["spirits"]=>array(2){[0]=>array(2){["id"]=>string(1)"1"["name"]=>string(5)"Foo"}[1]=>array(2){["id"]=>string(1)"2"["name"]=>string(3)"Bar"}}}我只是想提取下面的“id”和“name”键,以便在View中使用,但