我正在創建一個 Laravel 電子商務網站,并使用 Voyager 作為后端。我在創建網站的“訂單”部分時遇到了問題。我正在覆蓋訂單表的 voyager 視圖“read.blade.php”。我還將我的 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 回答
- 0 關注
- 165 瀏覽
添加回答
舉報
0/150
提交
取消