Laravelで以下のようなエラーログが出ております。
GetMasterLoginItemByLoginDay() はBuilderクラスには、
定義しておらず別のクラスで定義してそれを別のクラスから呼び出しております。
なぜこのようなエラーが出るのでしょうか?
●ログ
[2021-06-15 10:53:01] local.ERROR: Call to undefined method Illuminate\Database\Query\Builder::GetMasterLoginItemByLoginDay() {"exception":"[object] (BadMethodCallException(code: 0): Call to undefined method Illuminate\Database\Query\Builder::GetMasterLoginItemByLoginDay() at /var/www/html/SampleProject/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2483)
●呼び出し元
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Libs\MasterDataService; use App\UserProfile; use App\UserLogin; use App\MasterLoginItem; class LoginController extends Controller { 省略 $master_login_item = MasterLoginItem::GetMasterLoginItemByLoginDay($user_login->login_day); 省略 }
●呼び出し先
<?php namespace App; use Illuminate\Database\Eloquent\Model; use App\Libs\MasterDataService; class MasterLoginItem extends Model { protected $table = 'master_login_item'; public $incrementing = false; protected $primaryKey = 'login_day'; public $timestamps = false; public static function GetMasterLoginItem() { $master_data_list = MasterDataService::GetMasterData('master_login_item'); return $master_data_list; } public static function GetMasterLoginItemByLoginDay($login_day) { $master_data_list = self::GetMasterLoginItem(); foreach ($master_data_list as $master_data) { $master_login_item = new MasterLoginItem; $master_login_item->login_day = $master_data['login_day']; $master_login_item->item_type = $master_data['item_type']; $master_login_item->item_count = $master_data['item_count']; if ($login_day == $master_login_item->login_day) { return $master_login_item; } } return null; } }
回答1件
あなたの回答
tips
プレビュー