嗨,也许我在这里错过了一些东西,但是如果我使用的路线如
/管理用户的管理
然后刀片模板正确呈现。但是,使用确切的代码,使用路径
复制/粘贴到另一个视图中/管理/ {ID}
然后视图不呈现模板。
两个视图在每个方面都是相同的,一个用模板正确渲染视图,而另一个用slug渲染不能正确渲染模板,它会随机吐出元素但是它不能正确渲染实际的布局
他们为什么会有所不同?这不是我第一次遇到这个问题,我只是觉得如果一个slug在URL中有什么区别。
这两个文件再次相同。
一个是useraccounts函数,另一个是控制器上的show函数。
public function show($id)
{
$user=User::find($id);
return view('admin.show',compact('user'));
}
public function useraccounts()
{
$users = User::all();
return view('admin.useraccounts', compact('users'));
}
显示用户详细信息的按钮如下
<a href="{{route('admin.show',$user)}}" class="btn btn-primary">View all information</a>
请问我有没有关于这个问题的任何想法?
admin.show视图
@extends('admin')
@section('main')
<aside class="right-side">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Dashboard
<small>Control panel</small>
</h1>
<ol class="breadcrumb">
<li><a href="/admin"><i class="fa fa-dashboard"></i> Home</a></li>
<li class="active">Dashboard</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-green">
<div class="inner">
<h3>
{{--53<sup style="font-size: 20px">%</sup>--}}
</h3>
<p>
Statistics
</p>
</div>
<div class="icon">
<i class="ion ion-stats-bars"></i>
</div>
<a href="#" class="small-box-footer">
View Information <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div><!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-yellow">
<div class="inner">
<h3>
{{--53--}}
</h3>
<p>
User Management
</p>
</div>
<div class="icon">
<i class="ion ion-person-add"></i>
</div>
<a href="/admin-user-management" class="small-box-footer">
Edit Details <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div><!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-red">
<div class="inner">
<h3>
{{--65--}}
</h3>
<p>
Detailed Site Information
</p>
</div>
<div class="icon">
<i class="ion ion-pie-graph"></i>
</div>
<a href="#" class="small-box-footer">
View Data <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div><!-- ./col -->
</div><!-- /.row -->
<!-- top row -->
<div class="row">
<div class="col-xs-12 connectedSortable">
</div><!-- /.col -->
</div>
</section><!-- /.content -->
<label>{{$user->name}}</label>
</aside><!-- /.right-side -->
@endsection
然后使用
的admin.admin-user-management视图@extends('admin')
@section('main')
<aside class="right-side">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Dashboard
<small>Control panel</small>
</h1>
<ol class="breadcrumb">
<li><a href="/admin"><i class="fa fa-dashboard"></i> Home</a></li>
<li class="active">Dashboard</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-green">
<div class="inner">
<h3>
{{--53<sup style="font-size: 20px">%</sup>--}}
</h3>
<p>
Statistics
</p>
</div>
<div class="icon">
<i class="ion ion-stats-bars"></i>
</div>
<a href="#" class="small-box-footer">
View Information <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div><!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-yellow">
<div class="inner">
<h3>
{{--53--}}
</h3>
<p>
User Management
</p>
</div>
<div class="icon">
<i class="ion ion-person-add"></i>
</div>
<a href="#" class="small-box-footer">
Edit Details <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div><!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-red">
<div class="inner">
<h3>
{{--65--}}
</h3>
<p>
Detailed Site Information
</p>
</div>
<div class="icon">
<i class="ion ion-pie-graph"></i>
</div>
<a href="#" class="small-box-footer">
View Data <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div><!-- ./col -->
</div><!-- /.row -->
<!-- top row -->
<div class="row">
<div class="col-xs-12 connectedSortable">
</div><!-- /.col -->
</div>
</section><!-- /.content -->
<div class="container-fluid">
<div class="form-box">
@if (session('message'))
<div class="alert alert-info" style="text-align: center; width: 200px; ">
{{ session('message') }}
</div>
@endif
<div class="container">
{{-- @if(Auth::user()) --}}
<form class="form-group">
@if($users != null)
@foreach($users as $user)
@if($user->admin != 'true')
{!! Form::label($user->name) !!}
<div class="container">
<br>
<a href="{{route('admin.show', ['id' => $user->id])}}" class="btn btn-primary">View all information</a>
</div>
</br>
<div class="container">
{{-- <a href="{{route('house.edit',$house)}}" class="btn btn-primary">Update house details</a> --}}
</div>
<br>
<div class="container">
{{-- {!! Form::open(['method' => 'DELETE', 'route'=>['house.destroy', $house->id]]) !!} --}}
{{-- {!! Form::submit('Delete House', ['class' => 'btn btn-danger']) !!} --}}
{{-- {!! Form::close() !!} --}}
</div>
@endif
@endforeach
@else
{{-- <li><a href={{url('/house/create')}}>Add new house</a></li> --}}
@endif
</form>
{{-- @endif --}}
</div>
</div>
</div>
</aside><!-- /.right-side -->
@endsection
routes.php文件
//Admin Routes
Route::get('/admin-user-management', 'AdminController@useraccounts');
Route::resource('admin', 'AdminController');
标题
<head>
<meta charset="UTF-8">
<title>Admin | Dashboard</title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<!-- bootstrap 3.0.2 -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<!-- font Awesome -->
<link href="bootstrap/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<!-- Ionicons -->
<link href="bootstrap/css/ionicons.min.css" rel="stylesheet" type="text/css" />
<!-- Morris chart -->
<link href="bootstrap/css/morris/morris.css" rel="stylesheet" type="text/css" />
<!-- jvectormap -->
<link href="bootstrap/css/jvectormap/jquery-jvectormap-1.2.2.css" rel="stylesheet" type="text/css" />
<!-- fullCalendar -->
<link href="bootstrap/css/fullcalendar/fullcalendar.css" rel="stylesheet" type="text/css" />
<!-- Daterange picker -->
<link href="bootstrap/css/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<!-- bootstrap wysihtml5 - text editor -->
<link href="bootstrap/css/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css" rel="stylesheet" type="text/css" />
<!-- Theme style -->
<link href="bootstrap/css/AdminLTE.css" rel="stylesheet" type="text/css" />
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
答案 0 :(得分:1)
您的资产路径是相对的,它们应该是绝对的:
<link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
请注意/
之前的额外bootstrap/css/bootstrap.min.css
。如果缺少/
且您的网址为/admin/1
,则相对路径为/admin
,它将尝试在/admin/bootstrap/css/bootstrap.min.css
中找到引导程序CSS文件,如果当然没有&# 39; t存在。
这里最好的解决方案是在生成任何资产URL时使用asset
帮助函数,因为它将生成包含协议和域的完整URL,这样可以避免将来出现任何此类问题,如下所示:
<link href="{{ asset('bootstrap/css/bootstrap.min.css') }}" rel="stylesheet" type="text/css" />
asset
函数将生成如下所示的URL:
http://example.com/bootstrap/css/bootstrap.min.css
这意味着该位置始终是正确的。当然,您应该在从服务器加载所有资源时使用该功能,包括JavaScript文件,但不能使用从html5shiv
加载的maxcdn.com
等外部资源。