title: select id from post table where title=$title
body: <p>i have post table and i have comment table i have made them with laravel
  i made a IndexController and it has a method that returns all of my posts by their title;
  i also return and compact comment of each post and show them under each post content but i have to pass the post id to comment table by myself
  for example i have a post with id=7 and i have to pass the 7 to post_id column of comment table
  i have to write a query something like this</p>
  <pre><code>select id from posts where title=$title
  </code></pre>
  <p>with this query i want to select post id by post title and pass it to post_id in my comment table</p>
  <p>this my index controller</p>
  <pre><code>public function single($title)
  {
      $posts = Post::where('title', $title)-&gt;get();
  
      $comments = Comment::where([
          ['post_id', 7],
          ['verify',1]
      ])-&gt;orderBy('id', 'desc')-&gt;get();
      return view('main.single', compact('posts', 'comments'));
  }
  </code></pre>
  <p>this is comment controller</p>
  <pre><code>public function store(Request $request)
  {
      Comment::create([
          'post_id' =&gt; $request['post_id'],
          'user_id' =&gt; Auth::user()-&gt;id,
          'message' =&gt; $request['message'],
      ]);
  }
  </code></pre>
  <p>and also this my single blade file code</p>
  <pre><code>@foreach($comments as $comment)
              &lt;div class=&quot;container&quot;&gt;
                  &lt;div class=&quot;bg-secondary bg-opacity-10 p-3 mb-4&quot;&gt;
                      &lt;div&gt;
                          &lt;p class=&quot;fw-bold&quot;&gt;{{$comment-&gt;user-&gt;first_name.' '.$comment-&gt;user-&gt;last_name}}
                              &lt;br&gt;
                              &lt;span class=&quot;text-muted text-small-14 fw-light&quot;&gt;{{$comment-&gt;created_at}}&lt;/span&gt;
                          &lt;/p&gt;
  
                      &lt;/div&gt;
                      &lt;div class=&quot;mt-0&quot;&gt;
  
                      &lt;/div&gt;
                      &lt;div&gt;
                          {{$comment-&gt;message}}
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          @endforeach
  </code></pre>
  <p>and also i use laravel 8</p>