public function category_detail(Request $request,$slug)
{ $g_setting = GeneralSetting::where('id', 1)->first();
$property_page_data = PagePropertyItem::find(1);
$property_categories = PropertyCategory::get();
$property_locations = PropertyLocation::get();
$amenities = Amenity::get();
// Mülkleri sorgulamaya başlıyoruz
// Fetch the selected property category
$property_category_detail = PropertyCategory::where('property_category_slug', $slug)->first();
$properties = Property::with('user')->orderBy('id', 'desc');
if ($request->has('amenity')) {
$properties = $properties->whereHas('propertyAminities', function ($query) use ($request) {
$query->whereIn('amenity_id', $request->amenity);
});
}
if ($request->has('location')) {
$properties = $properties->whereIn('property_location_id', $request->location);
}
if ($request->has('category')) {
$properties = $properties->whereIn('property_category_id', $request->category);
}
if ($request->has('property_type')) {
if ($request->property_type == 'sale') {
$properties = $properties->where('property_type', 'For Sale');
} elseif ($request->property_type == 'rent') {
$properties = $properties->where('property_type', 'For Rent');
}
}
if ($request->has('text')) {
$properties = $properties->where('property_name', 'LIKE', '%' . $request->text . '%');
}
// Sonuçları sayfalandırıyoruz
$properties = $properties->paginate(15);
$properties->appends($request->except('page'));
$g_setting = GeneralSetting::where('id', 1)->first();
$property_category_page_data = PagePropertyCategoryItem::where('id', 1)->first();
$property_category_detail = PropertyCategory::where('property_category_slug',$slug)->first();
$property_items = Property::with('rPropertyCategory','rPropertyLocation')->where('property_category_id',$property_category_detail->id)->paginate(15);
return view('front.property_category_detail', compact(
'g_setting', 'property_category_detail', 'properties', 'property_page_data',
'property_categories', 'property_locations', 'amenities'
));
}kontroller kodum web.php
Route::get('Kategori/tumu', [PropertyControllerForFront::class,'category_all'])
->name('front_property_category_all');
Route::get('{slug}', [PropertyControllerForFront::class,'category_detail'])
->name('front_property_category_detail');
Route::get('Konum/tum-ilanlar', [PropertyControllerForFront::class,'location_all'])
->name('front_property_location_all');
Route::get('honaz-{slug}', [PropertyControllerForFront::class,'location_detail'])
->name('front_property_location_detail');
Route::get('agent/{type}/{id}', [PropertyControllerForFront::class,'agent_detail'])
->name('front_property_agent_detail');
Route::get('ilan-detay/', [PropertyControllerForFront::class,'property_result'])
->name('front_property_result');hata kodu ise şu ErrorException
Attempt to read property "id" on null
