亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么我的 @foreach 語句在 Laravel 中不起作用?

為什么我的 @foreach 語句在 Laravel 中不起作用?

PHP
大話西游666 2023-07-30 11:15:06
我正在創建一個 Laravel 電子商務網站,并使用 Voyager 作為后端。我在創建網站的&ldquo;訂單&rdquo;部分時遇到了問題。我正在覆蓋訂單表的 voyager 視圖&ldquo;read.blade.php&rdquo;。我還將我的 BREAD 鏈接到一個名為 OrdersController.php 的控制器。該文件如下(我添加的附加代碼如下):<?phpnamespace App\Http\Controllers\Voyager;use App\Order;use Validator;use App\iamlush;use Illuminate\Http\Request;use TCG\Voyager\Facades\Voyager;use TCG\Voyager\Events\BreadDataAdded;use TCG\Voyager\Events\BreadDataUpdated;use TCG\Voyager\Http\Controllers\VoyagerBaseController;class OrdersController extends VoyagerBaseController{? ? //***************************************? ? //? ? ? ? ? ? ? ? _____? ? //? ? ? ? ? ? ? ?|? __ \? ? //? ? ? ? ? ? ? ?| |__) |? ? //? ? ? ? ? ? ? ?|? _? /? ? //? ? ? ? ? ? ? ?| | \ \? ? //? ? ? ? ? ? ? ?|_|? \_\? ? //? ? //? Read an item of our Data Type B(R)EAD? ? //? ? //****************************************? ? public function show(Request $request, $id)? ? {? ? ? ? $slug = $this->getSlug($request);? ? ? ? $dataType = Voyager::model('DataType')->where('slug', '=', $slug)->first();? ? ? ? $isSoftDeleted = false;? ? ? ? if (strlen($dataType->model_name) != 0) {? ? ? ? ? ? $model = app($dataType->model_name);? ? ? ? ? ? // Use withTrashed() if model uses SoftDeletes and if toggle is selected? ? ? ? ? ? if ($model && in_array(SoftDeletes::class, class_uses_recursive($model))) {? ? ? ? ? ? ? ? $model = $model->withTrashed();? ? ? ? ? ? }? ? ? ? ? ? if ($dataType->scope && $dataType->scope != '' && method_exists($model, 'scope'.ucfirst($dataType->scope))) {? ? ? ? ? ? ? ? $model = $model->{$dataType->scope}();? ? ? ? ? ? }? ? ? ? ? ? $dataTypeContent = call_user_func([$model, 'findOrFail'], $id);? ? ? ? ? ? if ($dataTypeContent->deleted_at) {? ? ? ? ? ? ? ? $isSoftDeleted = true;? ? ? ? ? ? }
查看完整描述

2 回答

?
茅侃侃

TA貢獻1842條經驗 獲得超21個贊

錯誤提示找不到表。您需要通過在終端或命令行中輸入來遷移表php artisan migrate。



查看完整回答
反對 回復 2023-07-30
?
慕勒3428872

TA貢獻1848條經驗 獲得超6個贊

您可以在控制器頂部添加:

Use DB;

當我需要獲取或更改數據時,我總是需要使用它。


查看完整回答
反對 回復 2023-07-30
  • 2 回答
  • 0 關注
  • 165 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號