首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Laravel5.7变量在HTML5.7标记中被降低

Laravel5.7变量在HTML5.7标记中被降低
EN

Stack Overflow用户
提问于 2019-01-04 07:13:57
回答 1查看 31关注 0票数 0

我正试图在我的option标签中做一个三元操作。但是当我调用这个变量时,它变成了小写,而laravel却找不到它。

这是我的代码:

代码语言:javascript
复制
<select name="media_type" id="media_type" class="">
    <option value="">Select an option</option>
    <option value="image" {{ $campBanner->media_type == 'image' ? 'selected' : '' }}>Image</option>
    <option value="video" {{ $campBanner->media_type == 'video' ? 'selected' : '' }}>Video</option>
</select>

这是拉拉例外的结果:

代码语言:javascript
复制
<select name="media_type" id="media_type" class="">
    <option value="">Select an option</option>
    <option value="image" <?php echo e($campbanner->media_type == 'image' ? 'selected' : ''); ?>>Image</option>
    <option value="video" <?php echo e($campbanner->media_type == 'video' ? 'selected' : ''); ?>>Video</option>
</select>

ErrorException (E_ERROR) 未定义变量:大本营

是虫子吗?还是我搞砸了什么?

更新

这是我的控制器:

代码语言:javascript
复制
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\CampBanner;
use App\Http\Requests\StoreCampBanner;

class CampBannerController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
         return view('CampBanner.index', [
            'campBanner' => CampBanner::all()
         ]);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('CampBanner.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(StoreCampBanner $request)
    {
        CampBanner::create(
            $request->validated()
        );

        return ['message' => 'Banner Camp baru telah ditambahkan'];
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\CampBanner  $campBanner
     * @return \Illuminate\Http\Response
     */
    public function show(CampBanner $campBanner)
    {
         return view('CampBanner.show', compact('campBanner'));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\CampBanner  $campBanner
     * @return \Illuminate\Http\Response
     */
    public function edit(CampBanner $campBanner)
    {
        return view('CampBanner.edit', compact('campBanner'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\CampBanner  $campBanner
     * @return \Illuminate\Http\Response
     */
    public function update(StoreCampBanner $request, CampBanner $campBanner)
    {
        $campBanner->fill(
            $request->validated()
        )->save();

        return ['message' => 'Camp Banner berhasil diperbarui'];
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\CampBanner  $campBanner
     * @return \Illuminate\Http\Response
     */
    public function destroy(CampBanner $campBanner)
    {
        $campBanner->delete();
        return ['message' => 'Camp Banner berhasil dihapus.'];
    }
}
EN

回答 1

Stack Overflow用户

发布于 2019-01-04 17:49:42

把你的控制器代码,以便得到更好的帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54034526

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档