No connection could be made because the target machine actively refused it. (SQL: select * from `categories`)

Posted 1 week ago by alphadev

hello, to load categories from db to index page but it says: No connection could be made because the target machine actively refused it. (SQL: select * from categories)

controller:

   <?php

     namespace App\Http\Controllers;

     use App\Index;
     use App\Category;
     use Illuminate\Http\Request;

     class IndexController extends Controller
     {

         public function index()
         {
             $categories = Category::all();
             return view('index', comapct('categories'));
         }

index blade:

    @foreach($categories as $category)
            <div class="block1 hov-img-zoom pos-relative m-b-30">
                <img src="{{ asset('/images/frontend_images/banner-02.jpg') }}" alt="IMG-BENNER">

                <div class="block1-wrapbtn w-size2">
                    <!-- Button -->
                    <a href="#" class="flex-c-m size2 m-text2 bg3 hov1 trans-0-4">
                        {{ ucwords($category->category_name) }}
                    </a>
                </div>
            </div>
            @endforeach

Please sign in or create an account to participate in this conversation.