public function update(RecordRequest $request, $id)
 {
     $date = Carbon::now();
     $record = Record::findOrFail($id);
     $record->fill($request->all());
     $record->updated_at = $date;
     $record->save();
     return redirect()->route('registros.index');
 }
 private function createRecord(RecordRequest $request)
 {
     $record = Auth::user()->records()->create($request->all());
     $record->tags()->attach($request->input('tag_list'));
     return $record;
 }
 /**
  * Updates a new a biblio
  */
 public function update($id, RecordRequest $request)
 {
     $record = Record::findOrFail($id);
     $record->biblio = $request->get('biblio_id');
     $record->itemtype = $request->get('itemtype_id');
     $record->hidden = $request->get('hidden') != null ? true : false;
     $record->save();
     $fields = array();
     $field_index = 0;
     foreach ($request->get('fields') as $field) {
         if (isset($request->file('fields')[$field_index])) {
             $image = $request->file('fields')[$field_index]['value'];
             $basename = $image->getClientOriginalName();
             $extension = $image->getClientOriginalExtension();
             $filename = basename($basename, '.' . $extension);
             $image_name = $record->biblio . $record->itemtype . $field_index . '_' . $filename . '.' . $extension;
             $image->move(public_path() . '/images', $image_name);
         } else {
             $image_name = '';
         }
         if ($field['id'] == '') {
             $rec = new RecordField();
         } else {
             $rec = RecordField::findOrFail($field['id']);
         }
         $rec->record_id = $id;
         $rec->tagfield = $field['marcfield'];
         $rec->tagsubfield = $field['marcsubfield'];
         if ($image_name == '') {
             $rec->value = $field['value'];
         } else {
             $rec->value = $image_name;
         }
         $rec->save();
         $field_index++;
     }
     flash()->success('Record edited with success.');
     return redirect('admin/records');
 }