-1
@if($posts)
@foreach($posts as$post)
<h2>
<a href="{{route('home.post',$post->id)}}">{{$post->title}}</a>
</h2>
<p class="lead">
by <a href="index.php">{{$post->user->name}}</a>
</p>
<p><span class="glyphicon glyphicon-time"></span> Posted {{$post->created_at->diffForHumans()}}</p>
<hr>
<img class="img-responsive" src="{{$post->photo->file}}" alt="">
<hr>
{!! str_limit($post->body,35)!!}
<a class="btn btn-primary" href="{{route('home.post',$post->id)}}">Read More <span class="glyphicon glyphicon-chevron-right"></span></a>
<hr>
@endforeach
@endif
在控制器:
public function searchmulti(){
$keyword=Input::get('title');
$posts = Post::where('title', 'like', "%$keyword%")->get();
return view('Admin.comments.postsauthor',compact('posts'));
}
//////////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////// /////////////
拜託,你能通過代碼告訴我這個嗎?在此先感謝 –
我在編輯中添加了一些代碼,但此代碼未經測試 - 僅從內存 – neuronet
我試過並顯示此錯誤:嘗試獲取非對象的屬性在視圖 –