刀片未渲染Laravel

时间:2019-01-02 15:41:32

标签: php laravel laravel-blade

我的页面工作正常,但是我在不同的部分上工作,然后返回以纯文本形式找到它。 延伸线与所有其他页面完美配合

到目前为止我尝试过的事情:

  1. 删除了BOM,并确保文件为UTF-8
  2. 确保@extends在文件的开头
  3. 试图添加html标签
  4. 检查了任何无效字符
  5. 删除页面并将代码复制粘贴到新页面
  6. 确保同一目录中的其他刀片文件正在运行 一样,所以没有育儿问题或目录引用问题

我的刀片服务器页面代码(edit.blade.php):

@extends('layouts.app')

<body>

@section('content')
    <div class="row col-md-9 col-lg-9 col-sm-9 float-left">
        <div class="container">

        <form method = "post" action = "{{route('companies.update',[$company->id]) }}">
            {{csrf_field()}}

            {{-- //work around to post --}}
                  <input type ="hidden" name= "_method" value = "put"> 
                    <div class="form-group">
                        <label for="comapny-name">Name</label>
                        <input type="string" class="form-control" name='name' id="comapny-name" aria-describedby="emailHelp" placeholder="Enter company name" required value="{{$company->name}}">
                        <small id="helpText" class="form-text text-muted">We'll never share your informations with anyone else but Khalood because he is the website devloper :).</small>
                    </div>
                    <div class="form-group">

                        <label for="company-content">Description</label>
                        <textarea name='description'style = "resize: vertical" class="form-control autosize-target text-left" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter description" rows="5" >
                         {{$company->description}}</textarea>

                    </div>    
                    <div class="form-group">

                         <button type="submit" class="btn btn-primary">Submit</button>

                    </div>

                  </div>

                </div>



          <div class="col-sm-3 col-md-3 col-lg-3 float-right">

            <div class="sidebar-module">
              <h4>Actions</h4>
              <ol class="list-unstyled">
              <li><a href="/companies/{{$company->id}}">View Companies</a></li>
              <li><a href="/companies/">All Companies</a></li>

                <li><a href="#">Delete</a></li>
                <li><a href="#">Add new member</a></li>
              </ol>
            </div>
          </div><!-- /.blog-sidebar -->




   @endsection



  </body>

来自控制器的路由代码:

  public function edit($id)
    {
        $company = Company::where('id',$id )->first();
        return view('companies.edit',['company'=>$company]);

    }

还有将您转移到控制器的动作行:

      <li><a href="/companies/{{$company->id}}/edit">Edit</a></li>

app.blade.php随后。它应该工作正常,因为我正在其他许多页面中将其扩展并且工作正常。

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

<head>
{{-- adding the new theme css nad bootstraps we kedh --}}
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <meta name="description" content="">
        <meta name="author" content="">

        {{-- <title>Projects Managment Portal</title> --}}
        {{-- <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon">
        <link rel="icon" href="/favicon.ico" type="image/x-icon"> 
        Not working favicon
        --}}
        <!-- Custom fonts for this template -->
        <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
        <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
        <link href='https://fonts.googleapis.com/css?family=Kaushan+Script' rel='stylesheet' type='text/css'>
        <link href='https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
        <link href='https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700' rel='stylesheet' type='text/css'>


        <!-- CSRF Token -->
         <meta name="csrf-token" content="{{ csrf_token() }}">

         <title>{{ config('app.name', 'Laravel') }}</title>
         <!-- Scripts -->

         <script src="{{ asset('js/app.js') }}" defer></script>


        <!-- Bootstrap core CSS -->
        <link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
        {{-- Favicons css  for the nav bar icons--}}
        <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">




</head>

<body>
    <div id="app">

        <nav class="navbar navbar-expand-md navbar-light navbar-laravel">
            <div class="container">
                <a class="navbar-brand" href="{{ url('/') }}"><i class="fab fa-product-hunt"></i>rojacker</a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
                    <span class="navbar-toggler-icon"></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <!-- Left Side Of Navbar -->
                    <ul class="navbar-nav mr-auto">

                    </ul>

                    <!-- Right Side Of Navbar -->
                    <ul class="navbar-nav ml-auto">
                        <!-- Authentication Links -->
                        @guest
                            <li class="nav-item">
                                <a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
                            </li>
                        @else
                        <li class="nav-item">
                                <a class="nav-link" href="{{ url('/') }}"><i class="fas fa-home"></i> Home</a>
                        </li>

                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('companies.index') }}"><i class="far fa-building"></i> Companies</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('projects.index') }}"><i class="fas fa-project-diagram"></i> Projects</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('tasks.index') }}"><i class="fas fa-tasks"></i> Tasks</a>
                        </li>
 {{-- Admin Panel                        --}}
 @if (Auth::user()->role_id == 1)
 <li class="dropdown">
        <a id="navbarDropdown" class="nav-link dropdown" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
            Admin Panel <span class="caret"></span>
        </a>

        <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                <a class="nav-link" href="{{ route('projects.index') }}"><i class="far fa-building"></i>Projects</a>
                <a class="nav-link" href="{{ route('projects.index') }}"><i class="far fa-building"></i>Projects</a>

                <a class="nav-link" href="{{ route('projects.index') }}"><i class="far fa-building"></i>Projects</a>

        </div>
    </li>   
 @endif                       
                            <li class="nav-item dropdown">
                                <a id="navbarDropdown" class="nav-link dropdown" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre><i class="far fa-user-circle"></i>
                                    {{ Auth::user()->name }} <span class="caret"></span>
                                </a>

                                <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                                    <a class="dropdown-item" href="{{ route('logout') }}"
                                       onclick="event.preventDefault();
                                                     document.getElementById('logout-form').submit();"><i class="fas fa-door-open"></i>
                                        {{ __('Logout') }}
                                    </a>

                                    <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                                        @csrf
                                    </form>
                                </div>
                            </li>
                        @endguest
                    </ul>
                </div>
            </div>
        </div>    
        </nav>
    <div class="container">

        @include('partials.errors')
        @include('partials.success')


        <main class="py-4">
            @yield('content')
        </main>


    </div>

  <!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="../../dist/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>



 </body>




</html>

和包含公司部分的web.php部分:

Route::middleware(['auth'])->group(function(){


    // Creating Special Route to allow adding new project assigned to specific company id
    Route::get('/projects/create/{company_id?}', 'ProjectsController@create');

    Route::post('/projects/adduser/', 'ProjectsController@adduser')->name('projects.adduser');

    Route::resource('companies','CompaniesController');
    Route::resource('projects','ProjectsController');
    Route::resource('roles','RolesController');
    Route::resource('tasks','TasksController');
    Route::resource('users','UsersController');
    Route::resource('comments','CommentsController');



});

并链接到页面图像:

Page of the problem sceenshot

1 个答案:

答案 0 :(得分:0)

我找到了解决方案!

在迁移到新设计时它位于app.blade.php中(我没有注意到)摆脱了主要的css文件,只使用了嵌入在新模板中的bootstrap文件,它适用于网站的其余部分,但是编辑页面容器(我不知道为什么要这么做)需要原始的本机css文件,只需添加它即可,它的工作原理就像一个魅力!

简短的回答,很短,我在app.blade.php的标题中缺少此行

<link href="{{ asset('css/app.css') }}" rel="stylesheet">