index.blade.php 文件未返回任何视图或脚本?
index.blade.php file not returning any view or scripts?
我在最近的项目中遇到了一个问题,我试图通过数据库中的一个表单保存一些日期(按预期工作)但是当我试图从我的数据库中获取该数据时,它是在视图中没有显示任何东西(好像代码甚至不存在)甚至没有脚本,但相同的代码在另一个视图中工作。
控制器代码:
public function index()
{
$products = Product::all();
return view('product.index',compact('products'));
}
Blade代码:
@include('includes.header')
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12" style="margin: 30px" >
<table class="table table-bordered col-md-12 table-sm">
<thead>
<tr>
<th>ID</th>
<th>Image</th>
<th>Company Name</th>
<th>Title</th>
<th>Price</th>
<th>Status</th>
<th>Description</th>
<th>Created At</th>
<th>Updated At</th>
</tr>
</thead>
<tbody>
@if($products)
@foreach($products as $product)
<tr>
<td>{{$product->id}}</td>
<td><img src="" alt="">{{$product->photo ? $product->photo->file : 'no item photo'}}</td>
<td>{{$product->cname}}</td>
<td>{{$product->title}}</td>
<td>{{$product->price}}</td>
<td>{{$product->status == 1 ? "Active" : "Not Active"}}</td>
<td>{{$product->description}}</td>
<td>{{$product->created_at->diffForHumans()}}</td>
<td>{{$product->updated_at->diffForHumans()}}</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
</div>
</div>
<!-- /#page-wrapper -->
@include('includes.footer')
主要问题是它的行为就像未定义路由且未设置其视图(实际上并非如此)。我将其定义为
Route::resource('/admin/product','ProductController');
它正在返回我
如果定义了路由并且它不返回它的视图,这怎么可能。
I have created a custom route and view for it, and returned it's(index.blade.php) view to it and now it's working.
我在最近的项目中遇到了一个问题,我试图通过数据库中的一个表单保存一些日期(按预期工作)但是当我试图从我的数据库中获取该数据时,它是在视图中没有显示任何东西(好像代码甚至不存在)甚至没有脚本,但相同的代码在另一个视图中工作。
控制器代码:
public function index()
{
$products = Product::all();
return view('product.index',compact('products'));
}
Blade代码:
@include('includes.header')
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12" style="margin: 30px" >
<table class="table table-bordered col-md-12 table-sm">
<thead>
<tr>
<th>ID</th>
<th>Image</th>
<th>Company Name</th>
<th>Title</th>
<th>Price</th>
<th>Status</th>
<th>Description</th>
<th>Created At</th>
<th>Updated At</th>
</tr>
</thead>
<tbody>
@if($products)
@foreach($products as $product)
<tr>
<td>{{$product->id}}</td>
<td><img src="" alt="">{{$product->photo ? $product->photo->file : 'no item photo'}}</td>
<td>{{$product->cname}}</td>
<td>{{$product->title}}</td>
<td>{{$product->price}}</td>
<td>{{$product->status == 1 ? "Active" : "Not Active"}}</td>
<td>{{$product->description}}</td>
<td>{{$product->created_at->diffForHumans()}}</td>
<td>{{$product->updated_at->diffForHumans()}}</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
</div>
</div>
<!-- /#page-wrapper -->
@include('includes.footer')
主要问题是它的行为就像未定义路由且未设置其视图(实际上并非如此)。我将其定义为
Route::resource('/admin/product','ProductController');
它正在返回我
I have created a custom route and view for it, and returned it's(index.blade.php) view to it and now it's working.