title: Laravel - How to get model name or instance from route for store resource
body: <p>I am trying to get the model to get to the table name for a Form request, for validation to store a new model.
  I have several models that have the same structure in the tables (id, name, lang_id).
  There for, to keep my code as “DRY” as possible, I want to use the same validation for all of these models to check if the new entry is unique like so:</p>
  
  <pre><code>public function rules( Request $request) { 
    return [
      "nameFr"  =&gt; "required|unique:" . $table .",name|min:3|max:100",
      "nameEn"  =&gt; "required|unique:" . $table . ",name|min:3|max:100",
  ];
  </code></pre>
  
  <p>I have tested this in my update request in the Form request validation and I do get the table name, using this:</p>
  
  <pre><code>$table = collect( $this-&gt;route()-&gt;parameters() )-&gt;first()-&gt;getTable();
  </code></pre>
  
  <p>Trying it for the store request in the Form request validation:</p>
  
  <pre><code>$table = collect( $this-&gt;route()-&gt;parameters() );
  </code></pre>
  
  <p>Only returns an empty collection.</p>
  
  <p>It’s like the parameters have not yet been added to the route.</p>
  
  <p>I have a way to get it but it's not as clean using: </p>
  
  <pre><code>$table = explode( "/", $request-&gt;url()  ); // --&gt; returns an array
  
  array:5 [
    0 =&gt; "http:"
    1 =&gt; ""
    2 =&gt; "domain.local"
    3 =&gt; "admin"
    4 =&gt; "mymodels"
  ]
  </code></pre>
  
  <p>and then: </p>
  
  <pre><code>$table = end ($table); // --&gt; To get the last part of the uri which is the part I need "mymodels"
  </code></pre>
  
  <p>Should the URI change adding another segment to the URI, I could have to update the code.</p>
  
  <p>Any idea on how I could do this?</p>