public function update($section, $record_id) { $section = Section::find($section, 'slug'); if (!($record = Record::find($record_id))) { dd('record not found'); } $data = Data::where('record', '=', $record_id)->get(); foreach ($data as $item) { $item->delete(); } $this->store_data($section, $record); Functions::redirect(Settings::cloutURL() . '/sections/' . $section->slug); }