草庐IT

PAI-Blade

全部标签

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 split in blade 模板嵌套 foreach

我检索了一个由空格分隔的ID数组,如下所示@foreach($user_notify->user_notify_divisionsas$user_notify){{$user_notify}}@endforeach那么$user_notify的值就是ID$user_notify=2345我有一个数据库表division_listiddivision_name1工業製品卸・小売2繊維・衣料製造3繊維・衣料卸・小売4食品製造5食品卸・小売6医薬品製造现在如何使用上面的id字符串获取division_name谢谢大家! 最佳答案 在lar

php - Laravel 5.1 Blade(或只是简单的回显)错误地显示类

我的Laravel(5.1)View中有以下代码。PHPblock中的代码决定我应该将哪个类应用于下面的第一个td元素。@foreach($datesUnavailableas$dateUnavailable)unavailable_on);$creationDate=strtotime($dateUnavailable->created_at);$newformat=date('D,Md,Y',$unavailableDate);$createdBefore=($unavailableDate-$creationDate)/86400;if($createdBefore>=5){$c

php - Carbon formatLocalized 在 Blade 中不起作用

在BladeView中我有这段代码{{\Carbon\Carbon::setLocale("es")}}{{$registro->fecha_desde->format("ljFY")}}{{$registro->fecha_desde->formatLocalized("%A%d%B%Y")}}{{$registro->fecha_desde->diffForHumans()}}这不起作用,它返回:Friday30December2016Friday30December2016dentrode1semana因此,format()和formatLocalized总是以英文格式返回日期。

php - Laravel: Blade View 中的 undefined variable

这是AdminController.php:$images]);}}这是admin.blade.php:@extends('template')@section('title')AdminPage@endsection@section('header')@endsection@section('main')@if(Auth::check())@foreach($imagesas$image)id}}'>{{$image->content}}id}}/delete"method="post">Deletecaptionid}}/approve"method="post">Acceptim

php - 将数据从 Controller 传递到 Blade View laravel

我正在尝试通过href将参数发送到从事件列表到事件页面的页面。我的路线是Route::get('eventpage','EventController@index')->name('eventpage');我的事件Controller是query('id');$event=DB::table('events')->where('id',$id)->get();$pics=DB::table('pictures')->where('event_id',$id)->get();$n=count($pics);//thenumberofpicturesforaparticulareventr

php - 如何在 laravel Blade View 上定义变量数组?

我这样尝试:@foreach($categoriesas$category)@php$category[]=$category->name@endphp@endforeach{{implode(",",$category)}}如果执行代码,存在错误:undefinevariablecategory我该如何解决? 最佳答案 你可以简单地使用Laravel集合{{$categories->pluck('name')->implode(',')}}或者如果你想在foreach中这样做@php($names=[])@foreach($cat

php - undefined variable : editor (View:/home/marco/prova/resources/views/home. blade.php)

我有一个问题,Blade找不到变量:编辑器。这是我的Controller的功能。publicfunctionHomeText(){$data=[];$data['editor']=Editore::get();returnview('home')->with($data);}这些是文件blade.php中的说明:@foreach($editoras$editore){{$editore->id_editore,$editore->nome_editore}}@endforeach错误是什么?我希望你能帮助我!我是Laravel的新手,我想了解我哪里错了。 最

php - 未选中 Laravel Blade 复选框

我正在将变量从Controller传递到Blade中。这是我来自Controller的代码:$offerConditionsData=Offercondition::where('offerId',$id)->where('deleted','0')->get();returnview('Administrator.offers.add',$data);我在blade文件的顶部定义了一个变量:@if(isset($offerConditionsData))@foreach($offerConditionsDataas$offerConditions)@php$selectedCondC

php - 覆盖 laravel Blade 模板中的部分抛出 undefined variable 错误

我正在使用Laravel4和blade模板,但在尝试扩展模板时遇到了问题。在我的布局中有@yield('content')在我的页面中有@section('content')Welcome{{$name}}@stop效果很好,我创建了另一个与我的第一个非常相似的页面,只是想更改覆盖管理内容部分。模板中的其他部分没问题。所以我扩展我的页面,然后做@section('content')Hello!@stop我收到一个关于$name变量的未定义通知。我试过了@section('content')Hello!@overwrite同样,我收到通知错误。我检查了我的Controller,它使用了正