You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into an issue when creating the 'Orders' view on Voyager. I am overwriting the voyager view 'read.blade.php' for my order table. I also have my BREAD linked to a Controller called OrdersController.php, just like part 18 in the series.
Here is my OrderController.php:
<?phpnamespaceApp\Http\Controllers\Voyager;
useApp\Order;
useValidator;
useApp\iamlush;
useIlluminate\Http\Request;
useTCG\Voyager\Facades\Voyager;
useTCG\Voyager\Events\BreadDataAdded;
useTCG\Voyager\Events\BreadDataUpdated;
useTCG\Voyager\Http\Controllers\VoyagerBaseController;
class OrdersController extends VoyagerBaseController
{
//***************************************// _____// | __ \// | |__) |// | _ /// | | \ \// |_| \_\//// Read an item of our Data Type B(R)EAD////****************************************publicfunctionshow(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 selectedif ($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;
}
} else {
// If Model doest exist, get data from table name$dataTypeContent = DB::table($dataType->name)->where('id', $id)->first();
}
// Replace relationships' keys for labels and create READ links if a slug is provided.$dataTypeContent = $this->resolveRelations($dataTypeContent, $dataType, true);
// If a column has a relationship associated with it, we do not want to show that field$this->removeRelationshipField($dataType, 'read');
// Check permission$this->authorize('read', $dataTypeContent);
// Check if BREAD is Translatable$isModelTranslatable = is_bread_translatable($dataTypeContent);
// Eagerload Relations$this->eagerLoadRelations($dataTypeContent, $dataType, 'read', $isModelTranslatable);
$view = 'voyager::bread.read';
if (view()->exists("voyager::$slug.read")) {
$view = "voyager::$slug.read";
}
$order = Order::find($id);
$products = $order->iamlush; // this is my version of 'products'return Voyager::view($view, compact('dataType', 'dataTypeContent', 'isModelTranslatable', 'isSoftDeleted', 'products'));
}
}
Here you can see the section that takes the order and the products with it:
$order = Order::find($id); (this gets the order id)
$products = $order->iamlush; (this gets the product info and is there retutned below)
return Voyager::view($view, compact('dataType', 'dataTypeContent', 'isModelTranslatable', 'isSoftDeleted', 'products'));
My override 'read.blade.php' is the same as the normal apart from one section:
This should return all the data held in my database but instead, I get this error:
To see what was being output I added dd() just before the return:
$order = Order::find($id); (this gets the order id)
$products = $order->iamlushes; (this gets the product info and is there retutned below)
dd($products)
return Voyager::view($view, compact('dataType', 'dataTypeContent', 'isModelTranslatable', 'isSoftDeleted', 'products'));
And changed the '$order->iamlush' to different things here is the output:
I've run into an issue when creating the 'Orders' view on Voyager. I am overwriting the voyager view 'read.blade.php' for my order table. I also have my BREAD linked to a Controller called OrdersController.php, just like part 18 in the series.
Here is my OrderController.php:
Here you can see the section that takes the order and the products with it:
My override 'read.blade.php' is the same as the normal apart from one section:
This should return all the data held in my database but instead, I get this error:
To see what was being output I added dd() just before the return:
And changed the '$order->iamlush' to different things here is the output:
Here is my GitLab Repo: https://gitlab.com/rossi99/salonwebsite
Can SOMEONE HELP ME?!
The text was updated successfully, but these errors were encountered: