前提・実現したいこと
laravel5.4でプロジェクトを作成し、初期設定の状態から、
tasksテーブルのみを作成しました。
MySQL5.7のWorkbenchでtasksテーブルに1レコード作成し、laravelで結果を表示させたいのですが、上手く動かずエラーになります。
すごく初歩的なことが原因だと思いますが、原因わかる方教えてください。
発生している問題・エラーメッセージ
Call to undefined method Illuminate\Database\MySqlConnection::tables()
該当のソースコード
・web.php
php
1Route::get('/', function () { 2 $tasks = DB::tables('tasks')->get(); 3 return $tasks; 4});
・2018_04_20_020208_create_tasks_table.php
php
1<?php 2 3use Illuminate\Support\Facades\Schema; 4use Illuminate\Database\Schema\Blueprint; 5use Illuminate\Database\Migrations\Migration; 6 7class CreateTasksTable extends Migration 8{ 9 /** 10 * Run the migrations. 11 * 12 * @return void 13 */ 14 public function up() 15 { 16 Schema::create('tasks', function (Blueprint $table) { 17 $table->increments('id'); 18 $table->integer('user_id'); 19 $table->text('body'); 20 $table->timestamps(); 21 }); 22 } 23 24 /** 25 * Reverse the migrations. 26 * 27 * @return void 28 */ 29 public function down() 30 { 31 Schema::dropIfExists('tasks'); 32 } 33} 34
試したこと
補足情報(FW/ツールのバージョンなど)
php artisan serve
でローカルホストをサーバーにしています。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/20 04:23
2018/04/20 04:28