0

CustomDataStore( )という名前のモデルを作成しようとしていますmodels/custom_data_store.phpが、それは Eloquent を拡張しているため、テーブルの名前はcustom_data_storesですが、エラーが発生します。

Eloquent は という名前のテーブルを必要としていますcustomdatastores。もちろん、テーブル名を手動で設定することもできますが、そのような名前を自動的に設定するにはどうすればよいですか?

4

2 に答える 2

5

自動的に作成するには、モデルがmodels/custom/data/store.php

class Custom_Data_Store extends Eloquent
{

}
于 2012-12-28T22:09:32.810 に答える
0

モデルのファイル名にアンダースコアがある場合、laravelの雄弁家は実際には「見る」ことができないことに気付きました。内部で何が起こっているのかはよくわかりませんが (まだ初心者です)、これは私の観察に基づいているだけです..

私がしたことは

と という名前の 2 つの異なるモデルがtblReport_date.phpありtblReportdate.php、異なるテーブルを指していることを除いて、どちらも同じコードを持っています。

tblReportdate.phpコード:

<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class tblReportdate extends Eloquent implements UserInterface, RemindableInterface
{
    /**
 * The database table used by the model.
 *
 * @var string
 */
protected $table = 'tblClients';

    ...rest of the codes...

tblReport_date.phpコード:

<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class tblReportdate extends Eloquent implements UserInterface, RemindableInterface
{
    /**
 * The database table used by the model.
 *
 * @var string
 */
protected $table = 'tblReport_date';

    ...rest of the codes...

コントローラーには、このコードがあります

$db = tblReportdate::all();
return View::make('db.index')->with('db', $db);

その結果、ロードされるだけでロードtblReportdate.phpされません。tblReport_date.php

私は単独で抽出tblReport_date.phpしてテストしました..クラス名などに関係なく、常にエラーを返します..そしてIDKの理由. 誰かがこれを説明できる場合は、コメントアウトしてください..とにかく、ファイル名にアンダースコアを付けないでください XD

于 2014-05-23T05:56:46.360 に答える