当前位置: 首页 > 知识库问答 >
问题:

我无法删除这个错误,刀锋中laravel中的if语句的好结构是什么?

子车芷阳
2023-03-14

语法错误,意外的文件结尾(查看:/opt/lampp/htdocs/stdproject/smarttd/resources/views/admin/company/index.blade.php)“

我附上了index.blade.php的源代码

@extends('admin.layouts.inc.master')

@section('title','Company Information')

@push('css')

@endpush

@section('content')



    <div class="col-12">
        @include('admin.alert')
    </div>



<div class="col-md-12">

    <div class="card card-primary card-outline">
        <div class="card-header">
            <h5 class="m-0" id="heading">

                @if(count($companies) >0)
                    Edit existing company
                @else
                Add new company
                @endif

            </h5>

        </div>



        <form action="" id="company-form" method="POST" enctype="multipart/form-data">



            @if(count($companies) >0)
                @method('PUT')
            @endif


                @csrf
        <div class="card-body">


                    <div class="row">
                        <div class="col-6 mt-3">
                            <label for="company_name">Company Name</label>
                            <input type="text" class="form-control" id="company_name" name="company_name">

                            @error('company_name')
                            <small class="text-danger">{{ $message }}</small>
                            @enderror
                        </div>

                        <div class="col-6 mt-3">
                            <label for="company_logo">Company Logo</label>
                            <input type="file" class="form-control" id="company_logo" name="company_logo">
                            @error('company_logo')
                            <small class="text-danger">{{ $message }}</small>
                            @enderror
                        </div>

                        <div class="col-12 mt-3">
                            <label for="company_address">Company Address</label>
                            <textarea name="company_address" id="company_address" rows="4" class="form-control"></textarea>
                            @error('company_address')
                            <small class="text-danger">{{ $message }}</small>
                            @enderror
                        </div>

                        <div class="col-6 mt-3">
                            <label for="company_country">Company Country</label>
                            <input type="text" class="form-control" id="company_country" name="company_country">
                            @error('company_country')
                            <small class="text-danger">{{ $message }}</small>
                            @enderror
                        </div>

                        <div class="col-6 mt-3">
                            <label for="company_phone">Company Phone</label>
                            <input type="tel" class="form-control" id="company_phone" name="company_phone">
                            @error('company_phone')
                            <small class="text-danger">{{ $message }}</small>
                            @enderror
                        </div>

                        <div class="col-6 mt-3">
                            <label for="company_email">Company Email</label>
                            <input type="Email" class="form-control" id="company_email" name="company_email">
                            @error('company_email')
                            <small class="text-danger">{{ $message }}</small>
                            @enderror
                        </div>

                        <div class="col-6 mt-3" >
                            <label for="company_gst">Company GST</label>
                            <input type="text" class="form-control" id="company_gst" name="company_gst">
                            @error('company_gst')
                            <small class="text-danger">{{ $message }}</small>
                            @enderror
                        </div>
                    </div>
        </div>

            <div class="card-footer">
                <div class="row">
                    <div class="col-6">
                        <button onclick="companyFormSubmit()" class="btn btn-primary">Save Company Details</button>
                    </div>

                    <div class="col-6 text-right">
                        <a href="{{ route('admin.dashboard') }}" class="btn btn-secondary">Back</a>
                    </div>
                </div>
            </div>


        </form>
    </div>
</div>


@stop

@push('js')

    <script>

        function companyFormSubmit() {

            var heading =$('#heading').val();

            @if(heading=='Add new Company')
            {
                $('#company-form').attr('action','{{ route('admin.company.store') }}').submit();
            }
            @@endif

        }

    </script>

@endpush

共有1个答案

龙霖
2023-03-14

问题是在@push('js')中有@@endif而不是@endif

在刀片中,@@用于输出单个@,因此@@endif不会被解释为@if块的结尾。

请参阅刀片文档。

 类似资料:
  • 问题内容: i=0 for f in do echo “i value is $i” if [“$i” = “0”] then echo “here” i=$((i+1)) continue fi arr[i]=$f i=$((i+1)) done 在上面的bash脚本中,我在使用if语句时出现了一个错误,它看起来像这样 请指出我的错误。 问题答案: 采用 在bash,你需要周围的空间,并在条件

  • 问题内容: python中最好的方法是什么:if语句中的 OR 或 IN ?考虑性能和最佳实践。 要么 谢谢。 问题答案: 最好的方法是使用 set : 因为集合中的成员资格测试为O(1)(不变成本)。 其他两种方法的复杂度相同。只是固定成本的差异。测试既有清单又有链条短路;找到匹配项后立即终止。一种使用字节码跳转序列(如果为,则跳转到末尾),另一种使用C循环,如果值匹配则使用早期退出。在最坏的情

  • 我们可以像这样使用if-field: 但是这里有一些问题,我不明白为什么。 > 如果我运行(count已定义),则会引发错误: 我们能不能先分配一个值? 当我运行count=1 if False else l.append(count 1)(注意:count=0,l=[])时,将引发一个错误: l的结果是。 使用相同的条件,如果使用if-else块,则不会出现错误。 你能解释一下区别吗?

  • 问题内容: 对于我的工作,我必须开发一个小型Java应用程序,该应用程序可以解析非常大的XML文件(约30万行)以选择非常具体的数据(使用),因此我试图对其进行一些优化。我想知道这两个摘要之间哪个更好: 要么 其他详情: 这些if语句在循环内的每次迭代中执行(约20k次迭代) 的是一种在利用外部函数每次迭代计算 如果将设置为,则无需测试正则表达式是否匹配 谢谢你的帮助。 问题答案: 我遵循的一条黄

  • 问题内容: 注意到今天在我们的代码库中有一行代码,我认为肯定会因语法错误而使构建失败,但是测试通过了,显然它实际上是有效的python(在2.x和3中)。 条件表达式有时不需要空格: 如果LHS是变量,则不起作用: 但是它似乎仍然可以与其他类型的文字一起使用: 这是怎么回事,出于某种原因,它是否有意成为语法的一部分?这个奇怪的怪癖是已知/记录的行为吗? 问题答案: 令牌之间的空白 除逻辑行的开头或

  • 目前遇到此语法错误,错误发布在代码下方。 上面的代码,无法找出if语句上的语法错误。错误消息将很快粘贴为注释

  • 我在最后一行中找不到错误。我是这门语言的初学者。提前谢谢。 我的输出说最后一行。

  • 我试过这种格式 但这似乎不起作用。