WebページのコントローラとブレードファイルにはLaravelを使用しています。私のコードは次のようなものです:私が達成したいものをLaravel同じデータを取得してページを設定します
@foreach ($properties as $property)
<div class="geo">
<span class="lat">{{ $property->title }}</span>,
<span class="lng">{{ $property->description }}</span>
</div>
index.blade.php
でPropertiesController
$properties = Property::where('status', 1);
$properties = $properties->orderBy('properties.created_at', 'DESC')->paginate(8);
return view('properties.index')->with('properties', $properties);
カテゴリを取得することですw.r.t.プロパティと一緒にカウント、そのために、私はこれで
$properties = Property::where('status', 1);
$categories = array();
if (is_null($req->c)) {
$search = $properties;
foreach (Category::all() as $category) {
array_push(
$categories,
array(
'id' => $category->id,
'name' => $category->category,
'counts' => count($search->where('properties.category', $category->id)->get()),
)
);
}
}
$properties = $properties->orderBy('properties.created_at', 'DESC')->paginate(8);
return view('properties.index')->with('properties', $properties)->with('categories', $categories);
$search = $properties;
と
'counts' => count($search->where('properties.category', $category->id)->get()),
をやっていることは、非オブジェクトのプロパティを取得しようとすると
私に与え
<span class="lat"><?php echo e($property->title); ?></span>,
()にはどこで使用しましたか?を見せていただけますか? –