ルートでは完全に動作しますが、コントローラでは機能しません。何が間違っているのでしょうか?コントローラ内でstatmentに参加できませんLaravel 5.0
public function index()
{
$positions = DB::table('position')
->join('company', 'position.company_id', '=', 'company.id')
->select('position.*', 'company.name')
->get();
// Just to check if it's working
print_r($positions);
}
エラーが発生しますか? –
@AlexeyMezenin FatalErrorException PositionController.php行17: クラス 'App \ Http \ Controllers \ DB'が使用中に追加されない場合、Builder.php行でBadMethodCallExceptionが発生します。2258: 未定義メソッドを呼び出します。 Query \ Builder :: table() –
このコードをクラスの先頭に追加する必要があります。 'use DB;' – aldrin27