简体   繁体   English

在Laravel中使用未定义的常量

[英]Use of undefined constant in Laravel

I am having an issue with siteSocialSettingsData in my blade view I am getting 我在刀片视图中siteSocialSettingsData的问题

Use of undefined constant facebook - assumed 'facebook'

However I am confused as to why its happening as the GeneralSettings area/section is working how it should and they are both the same sections of code 但是,我对为什么它发生的原因感到困惑,因为GeneralSettings区域/部分正在按应有的方式工作,并且它们都是相同的代码部分

In my function I have done var_dump($siteSocialSettingsData->facebook); 在我的函数中,我完成了var_dump($siteSocialSettingsData->facebook); and it works as I want it 它可以按我想要的方式工作

Function: 功能:

$siteSettingsDB          = GeneralSettings::get();
$siteSettingsData        = $siteSettingsDB[0];

$siteSocialSettingsDB    = SocialSettings::get();
$siteSocialSettingsData  = $siteSocialSettingsDB[0]; 

return view('admin.pages.settings.general.general', compact('pageTitle','siteName', 'pageName', 'fullName','cpuUsage','memoryUsage', 'siteSettingsData', 'siteSocialSettingsData'));

Blade: 刀:

<input class="form-control updateField" data-id="facebook" data-url="{{ route('socialDataSubmit', facebook )}}" data-title="Facebook" name="facebook" placeholder="Facebook" type="input"  value="{{ old('facebook', $siteSocialSettingsData->facebook)}}"> <span class="input-group-btn"><button class="btn btn-default edit" type="button"><span class="glyphicon glyphicon glyphicon-pencil"></span></button></span>

You are just entering facebook without telling PHP if that's a variable or a string and that's why you're getting the error. 您只是进入facebook而没有告诉PHP这是变量还是字符串,这就是为什么出现错误的原因。 The error is in your blade view, at the data-url attribute, when you're calling the route function (check the second parameter). 错误是在刀片视图中的data-url属性中,当您调用route函数时(请检查第二个参数)。

You need to change your view to: 您需要将视图更改为:

<input class="form-control updateField" data-id="facebook"
    data-url="{{ route('socialDataSubmit', $siteSocialSettingsData->facebook )}}"
    data-title="Facebook" name="facebook" placeholder="Facebook" type="input"
    value="{{ old('facebook', $siteSocialSettingsData->facebook)}}">

<span class="input-group-btn">
    <button class="btn btn-default edit" type="button">
        <span class="glyphicon glyphicon glyphicon-pencil"></span>
    </button>
</span>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM