CustomDataStore
( )という名前のモデルを作成しようとしていますmodels/custom_data_store.php
が、それは Eloquent を拡張しているため、テーブルの名前はcustom_data_stores
ですが、エラーが発生します。
Eloquent は という名前のテーブルを必要としていますcustomdatastores
。もちろん、テーブル名を手動で設定することもできますが、そのような名前を自動的に設定するにはどうすればよいですか?
自動的に作成するには、モデルがmodels/custom/data/store.php
class Custom_Data_Store extends Eloquent
{
}
モデルのファイル名にアンダースコアがある場合、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