title: insert comma seprated values to database with validation models
body: <p>i have a input fields to insert names to the database at the moment it works like every time i enter one name  it inserts and does not allow duplications the name but i want to enter multiple names comma separated this si what i have at the moment</p>
  
  <p>front end</p>
  
  <pre><code>&lt;form method="POST" action="{{route('store.names')}}"&gt;
              @csrf
              &lt;div class="form-group row"&gt;
                  &lt;label for="names"
                         class="col-md-4 col-form-label text-md-right"&gt;Add New Name
                  &lt;/label&gt;
  
                  &lt;div class="col-md-6"&gt;
                      &lt;input id="names" type="text"
                             class="form-control @error('names') is-invalid @enderror" name="names"
                             value="{{ old('names') }}" autocomplete="names" autofocus&gt;
  
                      @error('names')
                      &lt;span class="invalid-feedback" role="alert"&gt;
                                          &lt;strong&gt;{{ $message }}&lt;/strong&gt;
                                      &lt;/span&gt;
                      @enderror
                  &lt;/div&gt;
              &lt;/div&gt;
      &lt;div class="form-group row mb-0"&gt;
                  &lt;div class="col-md-6 offset-md-4"&gt;
                      &lt;button type="submit" class="btn btn-primary"&gt;
                        Add Names
                      &lt;/button&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>    public function store(Request $request)
      {
  
          $validation = Names::create($this-&gt;validateRequest());
  
          return back()-&gt;with('message','Added'));
      }
  
     private function validateRequest()
      {
          return request()-&gt;validate([
              'names' =&gt; 'required|min:2|unique:Names',
          ]);
      }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/e0wV3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e0wV3.png" alt="enter image description here"></a>
  what this does is it inserts names of one person at a time how can i insert multiple people with comma separated with the validations intact</p>
  
  <p>but this iss what i need
  <a href="https://i.stack.imgur.com/VQcym.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VQcym.png" alt="enter image description here"></a></p>
  
  <p>i have figured it needs to be somthing like this</p>
  
  <pre><code>    $searchString = ',';
  
      if( strpos($request-&gt;names;, $searchString) !== false )
      {
        // insert in to db separately 
      }else{
          $names= Names::create($this-&gt;validateRequest());
      }
  </code></pre>