1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Class "App\Http\Controllers\DB" not foundの対処法

Posted at

エラーの背景

このようなタイプのエラーはFacadeで指定できていないのが原因です。

XXXController.php
//省略
use Illuminate\Support\Facades\DB; //これを追加

class TaskController extends Controller
{
    public function index()
    {
     
    $tasks = DB::table('tasks')->get(); //DBは省略形
    return view('task.index', ['tasks' => $tasks]);    
    }

use Illuminate\Support\Facades\DB;が必要です。
DBは省略形なので上のFacadesが必要です。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?