/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // $property = Property::findOrFail($id); $contractors = User::all(); $currentDevicesIds = []; $index = 0; foreach ($property->devices() as $device) { $currentDevicesIds[$index++] = $device->id; } $devices = Device::whereNotIn('id', $currentDevicesIds)->get(); // $devices = Device::all(); return View('properties.show', compact(['property', 'devices', 'contractors'])); }