在我的页面Controller中有$this->layout->content=View::make('authentication/login')->with('page_title','title');我正在为我的模板使用Blade文件。在html的头部,我有{{$page_title}}我得到一个错误,提示$page_title未定义。理想情况下,我想要的是$data=array('page_title'=>'Login','second_item'=>'value')...。但由于我无法将变量基本传递给View,所以我首先坚持这样做。 最佳答案
我正在尝试使用javascript和blade引擎编写一个简单的重定向,这是我想做的一个例子:javascript代码:ClickthebuttontogotothehomepageClickmefunctionmyFunction(){varx;varr=confirm("Areyousureyouwanttoleavethispage?");if(r==true){//Redirecttohome}else{//stayhere}document.getElementById("demo").innerHTML=x;}当我使用returnRedirect::route('home'
我有一个变量$country_code,它在我的表单的一部分显示正确的值,但在另一部分不显示。为什么会这样?这是我的代码:{{Form::open(['action'=>['PinVerificationController@valid'],'id'=>'pin_code_form'])}}//$country_codeshows1Wesentatextmessageto{{$country_code}}{{$phone_number}}.Youshouldreceiveitwithinafewseconds.{{Form::label('PinCode',null,['class'=
我有变量{{$template}}..我该怎么做才能将该变量包含到@extends中。我试过这样的:@extends({{$template}})//gettingerror我希望,有一个答案可以帮助我。谢谢。 最佳答案 你的意思是你想将$template的值传递给你的布局?以及从哪里获得$template的值?如果你想将变量传递给layout,那么尝试做@extends('>',['template'=>$template]) 关于php-如何将变量传递给@extendsblade,我
我从数据库中获取一些值,并将这些值传递到Controller的View中。现在我想在LaravelView中使用该数据和一些carbon函数。在我写的View文件中foreach($customeras$time){$create=$time->created_at;$update=$time->updated_at;$create_at_difference=\Carbon\Carbon::createFromTimestamp(strtotime($create))->diff(\Carbon\Carbon::now())->days;}当我这样尝试时,它返回"Class'Carb
我正在尝试在blade中获取小时、分钟和秒,通常我会像下面这样使用{{$calllog['delivery_date']}}但是现在我的要求是得到时分秒。这是我试图获得的方法$calllog['delivery_date']->todatestring()}}是的,我想我误用了这个功能,有人可以帮助我吗?我是Laravel的新手。任何帮助将不胜感激。 最佳答案 如果你的变量是DateTime,你可以使用这个:{{Carbon\Carbon::parse($calllog['delivery_date'])->format('H:i:
我正在将数据从我的Controller传递到我的blade文件,然后想将blade文件导出到word文档,到目前为止一切都已控制,我可以将blade导出到word文档,问题是文档无法打开Microsoftword说“word在1.docx中发现不可读的内容”。下面是我正在使用的代码$view=View::make('advertisement.advt_template.template_dr')->with('advtData',$advtData->first())->render();$file_name=strtotime(date('Y-m-dH:i:s')).'_adver
我在laravel中使用Auth::check函数。在所有Controller中它工作正常但在Blade文件中它不会工作。我遇到了这个错误Whoops,lookslikesomethingwentwrong.1/1FatalErrorExceptionin/var/www/html/laravel-master/storage/framework/views/e016f9336e75e5cb0b189c91cd736729b7184a61.phpline5:CalltoundefinedmethodIlluminate\Auth\AuthManager::check()ine016f9
我制作了一个带验证的表单(laravelwithbladetemplateengine)并且它按预期工作。代码如下:@if($errors->first('email')){{Form::text('email',null,$attributes=array('class'=>'error'))}}{{$errors->first('email',':message')}}@else{{Form::text('email')}}@endif是否有更清洁的解决方案?我只想写一次Form::text('email')... 最佳答案 这
我的问题是,我有页面作为LaravelBlade模板。如果用户登录,我的页面应该从主布局扩展。如果用户没有登录,我的页面应该从另一个主布局扩展。但是我的if-else语句不起作用@extends('layouts.outside');@extends('layouts.admin');我还尝试了bladeif-else版本如下:@if(Auth::check())@extends('layouts.outside')@else@extends('layouts.admin')@endif也没用。每当语句为真或为假时,if和else语句中的block都会在一个之后起作用。因为没有别的。我