林我routes.php文件,我有以下內容:Laravel基表或視圖沒有找到
<?php
Route::group(array(), function() {
View::share('roots', Category::roots()->get());
$tree = Category::get()->toHierarchy()->toArray();
View::share('categories', $tree);
Route::get('/', array('as' => 'home', 'uses' => '[email protected]'));
});
當我的數據庫沒有表還和我想要做的PHP工匠遷移 結果是:SQLSTATE [ 42S02]:基表或視圖未找到:1146表「ae_dev.categories」不存在
我的遷移文件:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCategoriesTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up() {
Schema::create('categories', function(Blueprint $table) {
$table->increments('id');
$table->integer('parent_id')->nullable()->index();
$table->integer('lft')->nullable()->index();
$table->integer('rgt')->nullable()->index();
$table->integer('depth')->nullable();
$table->string('name', 255);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down() {
Schema::drop('categories');
}
}
我認爲Laravel托盤從呼叫路由類別。 PHP和想要做選擇或思考,所以我想運行的遷移創建類別表,但上述錯誤產生前...
我該如何解決這個問題?
你讀過[本章](http://laravel.com/docs/4.2/schema) – worldask 2014-10-03 07:58:52
好像你有嘗試訪問數據庫的東西;你是否向你的工匠添加了任何命令或服務? – Repox 2014-10-03 08:07:23
不,我沒有向工匠添加任何新的命令或服務......問題不在遷移方面,我認爲,但你是對的... Route.php中的類別想要訪問數據庫,但爲什麼它接觸routes.php,如果我只想從命令行運行'php artisan'... – 2014-10-03 08:45:26