--- /dev/null
+<?php
+
+namespace Cubist\Backpack\Http\Controllers\Operations;
+
+use Cubist\Backpack\Magic\Models\CubistMagicAbstractModel;
+use Illuminate\Support\Facades\Route;
+
+trait InfosOperation
+{
+ protected function setupInfosRoutes($segment, $routeName, $controller)
+ {
+ Route::get($segment . '/{id}/infos', [
+ 'as' => $routeName . '.infos',
+ 'uses' => $controller . '@infos',
+ 'operation' => 'infos',
+ ]);
+ }
+
+ public function infos($id)
+ {
+ $this->crud->hasAccessOrFail('list');
+
+ // get entry ID from Request (makes sure its the last ID for nested resources)
+ $id = $this->crud->getCurrentEntryId() ?? $id;
+
+ // get the info for that entry
+ /** @var CubistMagicAbstractModel $entry */
+ $entry = $this->crud->getEntry($id);
+ $res = [];
+ if (method_exists($entry, 'getPageData')) {
+ $res = $entry->getPageData()->getRawData();
+ }
+
+ /* @foreach ($crud->columns() as $column)
+ <tr>
+ <td>
+ <strong>{!! $column['label'] !!}:</strong>
+ </td>
+ <td>
+ @if (!isset($column['type']))
+ @include('crud::columns.text')
+ @else
+ @if(view()->exists('vendor.backpack.crud.columns.'.$column['type']))
+ @include('vendor.backpack.crud.columns.'.$column['type'])
+ @else
+ @if(view()->exists('crud::columns.'.$column['type']))
+ @include('crud::columns.'.$column['type'])
+ @else
+ @include('crud::columns.text')
+ @endif
+ @endif
+ @endif
+ </td>
+ </tr>
+ @endforeach*/
+
+ $data = [];
+ $data['entry'] = $entry;
+ $data['crud'] = $this->crud;
+ $data['title'] = $this->crud->getTitle() ?? trans('backpack::crud.preview') . ' ' . $this->crud->entity_name;
+ $res['columns'] = [];
+ $this->crud->setShowColumns($entry);
+ foreach ($this->crud->columns() as $column) {
+ $data['column'] = $column;
+ $v = null;
+ if (view()->exists('vendor.backpack.crud.columns.' . $column['type'])) {
+ $v = view('vendor.backpack.crud.columns.' . $column['type'], $data);
+ } else {
+ if (view()->exists('crud::columns.' . $column['type'])) {
+ $v = view('crud::columns.' . $column['type'], $data);
+ } else {
+ $v = view('crud::columns.text', $data);
+ }
+ }
+ $res['columns'][$column['name']] = $v->render();
+ }
+
+
+ return response()->json($res);
+ }
+}
namespace Cubist\Backpack\Magic\Controllers;
use Cubist\Backpack\Http\Controllers\CubistCrudController;
+use Cubist\Backpack\Http\Controllers\Operations\InfosOperation;
+use Cubist\Backpack\Http\Controllers\Operations\ShowOperation;
use Cubist\Backpack\Magic\Fields\Field;
use Cubist\Backpack\Magic\Menu\Menu;
use Cubist\Backpack\Magic\Models\CubistMagicAbstractModel;
class CubistMagicController extends CubistCrudController
{
use HandleAjaxMedia;
+ use InfosOperation;
protected $_modelNamespace;
protected $_routeURL;
{
return $this->crud->getModel();
}
+
protected function _forgetCache()
{
try {
'filter' => false, 'filter_type' => $this->_filterType, 'filter_label' => null, 'filter_values' => $this->_filterValues,
'translatable' => $this->_translatable, 'migrateTranslatable' => $this->_migrateTranslatable,
'preview' => $this->_preview,
- 'column_type' => $this->_columnType, 'column_move_after' => $this->_columnMoveAfter, 'column_format' => $this->_columnFormat, 'column_width' => 300,
+ 'column_type' => $this->_columnType, 'column_move_after' => $this->_columnMoveAfter, 'column_format' => $this->_columnFormat, 'column_width' => 300, 'column_escape' => true,
'default' => null, 'cast' => $this->_cast, 'column_view_namespace' => $this->_columnViewNamespace, 'searchLogic' => $this->_searchLogic,
'allow_null' => true,
'can' => $this->_can, 'can_write' => $this->_canWrite, 'auth' => $this->_auth,
'searchLogic' => $this->getAttribute('searchLogic'),
'format' => $this->getAttribute('column_format', null),
'orderable' => true,
+ 'escape' => $this->getAttribute('column_escape', true),
];
if ($this->hasAttribute('column_function_name')) {