如果我在控制器,這條線會做到這一點。如何訪問視圖中的Laravel類?
use App\UBBUserSetting, App\UBBSetting;
但我在視圖中
我想包括在我看來,我的課(.blade.php)
我不能
use App\UBBUserSetting, App\UBBSetting;
$ubb_user_settings = UBBUserSetting::where('cpe_mac','=',$cpe_mac)->get();
$ubb_settings = UBBSetting::where('cpe_mac','=',$cpe_mac)->first();
if($ubb_settings != null){
$jump_bandwidth = $ubb_settings->jump_bandwidth;
$paid = $ubb_settings->price_per_jump;
}
$option2 = 0;
if($ubb_user_settings != null){
$option1_selected = [];
$option2_selected = [];
$lines = count($ubb_user_settings);
foreach ($ubb_user_settings as $i => $ubb_user_setting) {
if($ubb_user_setting->option == 1){
$option1_selected[$i]['d'] = $ubb_user_setting->created_at->format('d');
$option1_selected[$i]['threshold'] = (int)$ubb_user_setting->volume_current_limit;
}else{
$option2++;
$option2_selected[$i]['d'] = $ubb_user_setting->created_at->format('d');
$option2_selected[$i]['threshold'] = (int)$ubb_user_setting->volume_current_limit;
$option2_selected[$i]['next_threshold'] = $threshold + ($jump_bandwidth * $option2);
}
}
}
錯誤
一個如何去和這樣做?
任何提示?
這不是利益與Laravel是如何打算的工作有衝突?你不應該將數據傳遞給視圖,而不是在視圖中運行代碼? –