title: SQLSTATE[42S02]: Base table or view not found laravel
body: <p>So, going into the problem straight away. someone told me that we dont need to make a <code>pivot table</code> if we only want to have <code>ids</code> of the table. laravel can itself handle this situation. I dont know how this works. I have a table <code>community</code> and another table <code>idea</code>. relation is like this; </p>
  
  <blockquote>
    <p>One community can contain many ideas and an idea can be found in many
    communities.</p>
  </blockquote>
  
  <p><strong>Relation in idea Model:</strong></p>
  
  <pre><code> public function community() {
          return $this-&gt;belongsToMany('App\Community')-&gt;withTimestamps();
      }
  </code></pre>
  
  <p><strong>Relation in community Model:</strong></p>
  
  <pre><code> public function idea() {
          return $this-&gt;belongsToMany('App\idea');
      }
  </code></pre>
  
  <p>Now i want to fetch all the records related to a single community to show on its page Let's say the community is <code>Arts</code>. </p>
  
  <p><strong>Here is Controller function:</strong></p>
  
  <pre><code> public function showCommunities($id) {
      $community = Community::findOrFail($id)-&gt;community()-&gt;get();
      return view('publicPages.ideas_in_community', compact('community'));
     }
  </code></pre>
  
  <p>When i attach <code>-&gt;community()-&gt;get()</code> to the  <code>Community::findOrFail($id)</code> Then it throws the error </p>
  
  <blockquote>
    <p>SQLSTATE[42S02]: Base table or view not found laravel</p>
  </blockquote>
  
  <p>Any help would be appreciated.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Logically, this piece of code <code>Community::findOrFail($id)-&gt;community()-&gt;get()</code> should be like this <code>Community::findOrFail($id)-&gt;idea()-&gt;get()</code>. Now it is true but it has little issue. it throws an error </p>
  
  <blockquote>
    <p>Fatal error: Class 'App\idea' not found</p>
  </blockquote>