如何将其更改为非使用redis。在.env我没有redis作为DB_CONNECTION。 idk我怎么能降低这个redis,因为没有ingerence我无法启动我的网站...大thx帮助和任何答案。
这是我的controller.php,其中31-33
中的错误<?php
namespace App\Http\Controllers;
use Auth;
use LRedis;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
abstract class Controller extends BaseController
{
use DispatchesJobs, ValidatesRequests;
public $user;
public $redis;
public $title;
public function __construct()
{
$this->setTitle('Title not stated');
if(Auth::check())
{
$this->user = Auth::user();
view()->share('u', $this->user);
}
$this->redis = LRedis::connection();
view()->share('steam_status', $this->getSteamStatus());
}
public function __destruct()
{
$this->redis->disconnect();
}
public function setTitle($title)
{
$this->title = $title;
view()->share('title', $this->title);
}
public function getSteamStatus()
{
$inventoryStatus = $this->redis->get('steam.inventory.status');
$communityStatus = $this->redis->get('steam.community.status');
if($inventoryStatus == 'normal' && $communityStatus == 'normal') return 'good';
if($inventoryStatus == 'normal' && $communityStatus == 'delayed') return 'normal';
if($inventoryStatus == 'critical' || $communityStatus == 'critical') return 'bad';
return 'good';
}
}
这是我的.env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=l2ggh1imVxJ7Oj6BotPUWinAIDgJfBYw
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=csgo
DB_USERNAME=root
DB_PASSWORD=secret
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=localhost
REDIS_PASSWORD=null
REDIS_PORT=4563
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
pplssss帮助我!
答案 0 :(得分:0)
您可以像这样访问数据库表 首先,您需要在文件顶部添加此代码
use Illuminate\Support\Facades\DB;
然后
$steamDetail= DB::table('steam')->get();//This will return all the data from steam table
$steamStatusArray=DB::table('steam')->pluck('status');//This will return only the status column from steam table
Reference- Laravel Query Builder
注意:您必须删除与LRedis
相关的所有代码
如果你不知道从哪里开始试试这个 tutorial 。它可能会给你这个想法。