Php 在laravel视图中显示来自sqlite的数据时出现问题?

Php 在laravel视图中显示来自sqlite的数据时出现问题?,php,laravel,Php,Laravel,我正在使用mysqlite数据库和laravel进行实践。我使用php artisan make:model Channel--fmc命令创建了一个模型,然后在迁移文件中包含name字段并运行php artisan migrate。通过使用php artisan tinker,我填充了database/database.sqlite文件。通过运行 tinker上的App\Channel::all()显示所有记录。但问题是,当我试图获取ChannelController.php中的所有记录时,它会

我正在使用mysqlite数据库和laravel进行实践。我使用php artisan make:model Channel--fmc命令创建了一个模型,然后在迁移文件中包含name字段并运行php artisan migrate。通过使用php artisan tinker,我填充了database/database.sqlite文件。通过运行 tinker上的App\Channel::all()显示所有记录。但问题是,当我试图获取ChannelController.php中的所有记录时,它会显示错误。我的代码中的问题在哪里

ChannelController.php


namespace App\Http\Controllers;

use App\Channel;
use Illuminate\Http\Request;

class ChannelController extends Controller
{
    public function index()
    {
       $channels = Channel::all();

       dd($channels->name);

       return view('channel.index',compact($channels));
    }
}
web.php

Route::get('channels','ChannelController@index');
ChannelFactroy.php

use App\Channel;
use Faker\Generator as Faker;

$factory->define(Channel::class, function (Faker $faker) {
    return [
        'name' => $faker->word,
    ];
});
错误


您好,Muhammad,您收到这个错误是因为mysql试图告诉您没有服务器在运行。尝试重新启动服务器。我认为您会出现此错误,因为防火墙阻止了连接,或者承载服务的进程没有在该端口上侦听。检查您的运行端口列表。
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it.
 (SQL: select * from `channels`)
   catch (Exception $e) {

            throw new QueryException(

                $query, $this->prepareBindings($bindings), $e

            );

        }