public function receiveMoist(Request $request) { $all = $request->all(); $plantPlots = PlantPlot::all(); foreach ($plantPlots as $plantPlot) { if (count($plantPlot->plant)) { $moisture = new Moisture(); $moisture->date = Carbon::now(); $moisture->value = $request->get($plantPlot->pin); $plantPlot->plant->moisture()->save($moisture); } } return $all; }
public function getPlants() { $plantPlots = PlantPlot::all(); return view('admin.plants', compact('plantPlots')); }