title: Laravel polymorphic relation load model by morph name and foreign key
body: <p>I am trying to create a comment to a commentable model (which is created by using polymorphic relations.) using the morphname key.</p>
  
  <p>For example; i would like create a comment giving the morph name (blog) and foreign_key (1). But the morph name could change. So we don't know which key can be with the request. I don't want to create actions for each resource.</p>
  
  <p>AppServiceProvider:</p>
  
  <pre><code>Relation::morphMap([
      'blog' =&gt; \App\Models\Blog\BlogPost::class,
      'product' =&gt; \App\Models\Commerce\Product::class,
  ]);
  </code></pre>
  
  <p>Conroller -> action:</p>
  
  <pre><code>$this-&gt;validate($request, [
      'commentable_model' =&gt; 'required|string',
      'commentable_id' =&gt; 'required|integer|min:1',
      'comment' =&gt; 'required|string'
  ]);
  
  // i am trying to load data using morph name and foreign key here; but it's not working.
  $model = $request-&gt;commentable_model::findOrFail($request-&gt;commentable_id);
  
  $comment = new Comment;
  $comment-&gt;comment = $request-&gt;comment;
  $comment-&gt;commentable()-&gt;associate($model);
  $comment-&gt;user()-&gt;associate(auth('api')-&gt;user());
  $comment-&gt;save();
  </code></pre>
  
  <p>Commentable relation:</p>
  
  <pre><code>Schema::create('comments', function (Blueprint $table) {
      $table-&gt;increments('id');
      $table-&gt;integer('user_id')-&gt;unsigned();
      $table-&gt;text('comment');
      $table-&gt;integer('parent_id')-&gt;unsigned()-&gt;nullable();
      $table-&gt;foreign('parent_id')-&gt;references('id')-&gt;on('comments')-&gt;onDelete('cascade');
      $table-&gt;morphs('commentable');
      $table-&gt;timestamps();
  });
  </code></pre>
  
  <p>Data:</p>
  
  <blockquote>
    <p>commentable_model => 'blog',
    commentable_id => 1</p>
  </blockquote>
  
  <p>I will send these data via api endpoints. So, i would like to use just morhpnames, not full class names.</p>
  
  <p>I could not get it work.</p>
  
  <p>Any ideas?</p>