[英]View [.] not found
I have an error when displaying the home page, I used foreach to display two tables but when I added the third i just found this error : View [.] not found.显示主页时出现错误,我使用 foreach 来显示两个表,但是当我添加第三个表时,我才发现此错误:未找到视图 [.]。 this is the code Controller :这是代码控制器:
public function try () {
$post =actu::orderBy('created_at','desc')->get();
$ville=Villle::orderBy('Ville','desc')->get();
$specialité=speec::orderBy('id','desc')->get();
return view ('/',['sp'=>$specialité],['vi'=>$ville],['pub'=>$post]);
}
and added this to the home page :并将其添加到主页:
<form action="{{route('hi')}}" method="get">
<input type="text" class="search-field business" name="rech" value="" placeholder ="Cherchez..">
<select type="text" class="search-field location" name="spec" id="s" value="spec" placeholder ="Spécialités">
<option selected></option>
@foreach($sp as $ss)
<option value=" {{$ss->Spécialité}}"> {{$ss->Spécialité}}</option>
@endforeach
</select>
<select type="text" class="search-field location" name="Région" value="Région" placeholder ="Région">
<option selected></option>
@foreach($vi as $vv)
<option value="{{$vv->Ville}}">{{$vv->Ville}}</option>
@endforeach
</select>
<button class="search-btn" type="submit" id="search"> Recherche </button>
</form>
<section>
@foreach($pub as $p)
<h1> {{$p->Titre}}</h1>
<h3> {{$p->Contenu}}</h3>
<h3> {{$p->Photo}}</h3>
@endforeach
And this is the route :这是路线:
Route::get('/','Specialite@try');
please how can i solve this problem ?请问我该如何解决这个问题?
if your view file is in here : directory/view.blade.php如果您的视图文件在这里:目录/view.blade.php
Then your controller should be like this:那么你的控制器应该是这样的:
public function try () {
$post =actu::orderBy('created_at','desc')->get();
$ville=Villle::orderBy('Ville','desc')->get();
$specialité=speec::orderBy('id','desc')->get();
return view ('directory.view',[
'sp'=>$specialité,
'vi'=>$ville],
'pub'=>$post
]);
}
1) You name the html file as home.blade.php
over this path resoursces/views/home.blade.php
1)您在此路径resoursces/views/home.blade.php
html 文件命名为home.blade.php
resoursces/views/home.blade.php
view() should contain template blade file name(home) and not the path ('/') view() 应该包含模板刀片文件名(home)而不是路径('/')
public function try () {
$post =actu::orderBy('created_at','desc')->get();
$ville=Villle::orderBy('Ville','desc')->get();
$specialité=speec::orderBy('id','desc')->get();
return view ('/',['sp'=>$specialité],['vi'=>$ville],['pub'=>$post]);
}
Replace the '/' to 'home'将“/”替换为“家”
public function try () {
$post =actu::orderBy('created_at','desc')->get();
$ville=Villle::orderBy('Ville','desc')->get();
$specialité=speec::orderBy('id','desc')->get();
return view ('home',['sp'=>$specialité],['vi'=>$ville],['pub'=>$post]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.