title: Backpack for Laravel - Upload CSV and Store as JSON in Database
body: <p>I have successfully configured Backpack for Laravel to handle all of the CRUD  ops for my app except for one particular field. I need to import a CSV, convert it to JSON and then store the JSON in my database to later display as an HTML table. </p>
  
  <p>I created a custom field in Backpack, which does in fact create a field to upload the file, but I can't figure out how to point it to a custom method to handle the logic to handle the conversion and storing of the CSV.</p>
  
  <p>I have combed the documentation but I don't see any mention of anything like this. <a href="https://backpackforlaravel.com/docs/3.4/crud-fields#creating-a-custom-field-type" rel="nofollow noreferrer">https://backpackforlaravel.com/docs/3.4/crud-fields#creating-a-custom-field-type</a></p>
  
  <pre><code>//Placed in the Controller CrudPanel Configuration
  $this-&gt;crud-&gt;addField([
    // CSV to JSON
    'label' =&gt; "Specs Table",
    'name' =&gt; "specifications_table",
    'type' =&gt; 'csv2json', //custom field name
  ], 'update/create/both');
  
  //Placed in csv2json.blade.php file
  &lt;div @include('crud::inc.field_wrapper_attributes') &gt;
    &lt;label&gt;{!! $field['label'] !!}&lt;/label&gt;
    &lt;input
        type="file"
        name="{{ $field['name'] }}"
        value="{{ old($field['name']) ? old($field['name']) : (isset($field['value'])     ? $field['value'] : (isset($field['default']) ? $field['default'] : '' )) }}    "
        @include('crud::inc.field_attributes')
    &gt;
  
    {{-- HINT --}}
       @if (isset($field['hint']))
          &lt;p class="help-block"&gt;{!! $field['hint'] !!}&lt;/p&gt;
       @endif
  &lt;/div&gt;
  </code></pre>