title: How to write this same code and get same data in eloquent relationship ... laravel
body: <p>How to write this same code and get same data in eloquent relationship</p>
  <pre><code> public function index(){
      
      $data = DB::table('categories')
      -&gt;join('subcategories', 'categories.id', 'subcategories.cat_id')
      -&gt;select('categories.*', 'subcategories.*')-&gt;paginate(5);
      return view ('admin.subcategory.index', compact('data'));
  } 
  </code></pre>