public function run() { DB::table('farmunits')->delete(); $collection = [['loan_id' => 1, 'farm_id' => 1, 'practice' => 'IR', 'acres' => 1000], ['loan_id' => 1, 'farm_id' => 1, 'practice' => 'NI', 'acres' => 2350], ['loan_id' => 1, 'farm_id' => 2, 'practice' => 'NI', 'acres' => 50], ['loan_id' => 1, 'farm_id' => 3, 'practice' => 'IR', 'acres' => 200], ['loan_id' => 1, 'farm_id' => 4, 'practice' => 'IR', 'acres' => 400], ['loan_id' => 2, 'farm_id' => 5, 'practice' => 'NI', 'acres' => 4347.4]]; foreach ($collection as $record) { Farmunit::create($record); } }
public function update($id) { // save updated $record = $this->records->find($id); if (!$record) { Farmunit::create(Input::all()); return $this->respond($record); } $record->fill(Input::all())->save(); return $this->respond($record); }