At the moment, in the show view file, there's only a dump() of the Model.
May we consider to improve this to display user-friendly data of Models?
I'm ok to start it! ;)
Hi @welcoMattic ,
Yes, it was planned all along, it's just been postponed because of more pressing features. I'm very happy to help you out if you want to get started before I find the time. There are a few issues that need to be addressed. Here are my thoughts:
<td> when loading those views;$this->crud->addShowColumn(); // add one column, at the end of the stack
$this->crud->addShowColumns(); // add multiple columns, at the end of the stack
$this->crud->removeShowColumn('column_name'); // remove a column from the stack
$this->crud->removeShowColumns(['column_name_1', 'column_name_2']); // remove an array of columns from the stack
$this->crud->setShowColumnDetails('column_name', ['attribute' => 'value']);
$this->crud->setShowColumnsDetails(['column_1', 'column_2'], ['attribute' => 'value']);
CrudController::show() method should be separated into a trait; it's a Resourceful Controller feature, after all; or should we move all of them into traits?Backpack\CRUD\PanelTraits\Show.php;Backpack\CRUD\PanelTraits\AutoSet::setFromDb() should also autoset the Show Columns, just like it does with Columns and Fields;show.blade.php so that's good;$this->crud->enableShow();;@welcoMattic , what do you think? If you do want to work on this, after we pen down the solution I could create a feature branch for you, so we can collaborate there.
Cheers!
@tabacitu Woh such a reply! Indeed you've been working on it, I'm ok to continue this work on a separate feature branch.
For now, in my application, I just patch the feature with some Blade tricks in the show view, only. But it could be nice to make properly in CRUD feature.
Go on!
@tabacitu @welcoMattic hows this coming along?
Is there any update on this?
Hi @skatika @OwenMelbz @tabacitu!
Last weeks were very full of work, I didn't have much time to work on it. With Xmas period coming I don't know if I could work a lot on this feature. But trust me, in January I'll plan some evenings to work on BackPack, especially on show view ;)
@tabacitu @OwenMelbz @skatika PR is open 馃帀
@welcoMattic @tabacitu @OwenMelbz If you guys don't mind, I'd like to take a crack at implementing this based on the specs detailed in https://github.com/Laravel-Backpack/CRUD/issues/226#issuecomment-258803994. I have a pressing need and would prefer to implement it in a style that's compatible with the current infrastructure. This would probably not use much from the pending PR.
Basically the approach would be to render a 2-column bootstrap table in the show view using the existing column-type names and views, taking a single row and rendering it vertically -- column one containing the headers and column 2 containing the row data. I would name the elements 'showRow' instead of 'showColumn' and autopopulate using the same selection process as fields rather than restrict show to the column limitations.
If this works for everybody I'd be happy to discuss further, including how you would like me to coordinate the work. I'm probably going to need to implement something in the next few weeks.
I don't know exactly how this is going along, I just wanted to share my approach I just implemented in one of my projects.
Basic overview of what I did:
edit.blade.php to my project's show.blade.php (apart from some differences), adjusted a couple of things (mostly strings)$this->data['fields'] = $this->crud->getUpdateFields($id); to show() methodshow.blade.php:jQuery(document).ready(function($) {
$('form').find(':input').prop('disabled', true);
});
@include('crud::inc.form_save_buttons')It takes all the fields specified for editing and disables them (it also works for select2 inputs).
I'm not saying it's the most beautiful thing under the Sun, but it's still better than dump() approach and it doesn't look like a breaking change to me.
Possible drawbacks:
Maybe this'll help someone, at least until the new approach is implemented.
Hi guys,
I'm sorry for months of silence. I've really no time to work on this feature. Actually I'm working on Symfony projects. If someone is interested to take this issue, he/she is welcome ;)
Hi @welcoMattic ,
Thanks a lot for the update! No worries, I'll pick it up in Backpack 3.4.
I imagine it's a pretty frustrating transition from Laravel to Symphony, so good luck with that :-)
Cheers!
In other REST implementations I've seen, to view a resource, you would use something like /tags/1 where 1 is the id of the resource. So,
/tags -> list all tags
/tags/create -> create a new tag
/tags/1 -> show details of tag with id 1
/tags/1/edit -> edit tag with id 1
If I understand correctly, you're saying you would have something like /tags/1/show or /tags/show/1?
Here's how this could turn up iteratively:
create or edit functionality (doesn't matter which) and then filter every input field to be disabled (and remove the submit buttons).And suddenly you've got an odd looking but workable preview.
Then:
I'll call this the "bike shedding" step :)
@mmickelson - the route is already there, it's exactly as you suggested, RESTful (/tags/1). I agree with you that a different route makes no sense.
@lloy0076 - I thought about showing everything in fields too, but it definitely won't look good by default :-) Another problem here - you might show some fields on CREATE, others on UPDATE. Which ones would be visible on SHOW? Plus, you'd have things like ID that you might want visible on SHOW, but not on CREATE or UPDATE... It's tricky...
@tabacitu I'm still willing to take this on as an assigned task, implemented the way you have specified, as I described in my previous https://github.com/Laravel-Backpack/CRUD/issues/226#issuecomment-296384652. There shouldn't be any breaking changes.
@tabacitu - aye, I agree it wouldn't look particularly pretty; I was more thinking that a stepping stone towards making it look pretty would be an almost copy/paste of the create or update workflow, get that working, and then make it pretty.
@jonphipps - if I'm reading https://github.com/Laravel-Backpack/CRUD/issues/226#issuecomment-296384652 correctly, then I think we might be saying the same thing in different ways :)
@lloy0076 re: "I think we might be saying the same thing in different ways :)" Not exactly. I'm talking about copying the _column_ default definitions and views, intact, and simply defining a 'show' view of a Db row as a single row from the 'list' view, rather than redisplaying the create/update definitions. The column definitions are much more appropriate for showing a single row from the list columns and the current column API is a better fit.
@jonphipps - ah, yes, that would work.
However, consider:
In addition, if one were to "steal" the code for addFields then one might be able to get the tab feature for free. I'm not sure but I'm fairly certain one could.
Really, where we differ might be:
addShowFields([])) or (addFields([], 'show'))" and then reuse the current addShowField code _somehow_That said, I'm sure everyone would appreciate a PR based on what you've suggested.
@lloy0076 I'm going by the requirements defined in this set of specs from @tabacitu and reiterated here:
$this->crud->addShowRow();
instead of
$this->crud->addShowColumn();
<table id="crudTable" class="table table-bordered table-striped display">
<thead><tr><td>Field</td<td>Value></td></tr></thead>
<tbody>
<tr>
<td>{{ $showRow['label']}}<td>
{{-- load the view from the application if it exists, otherwise load the one in the package --}}
@foreach ($crud->showrows as $showRow)
@if (!isset($showRow['type']))
@include('crud::columns.text')
@else
@if(view()->exists('vendor.backpack.crud.columns.'.$showRow['type']))
@include('vendor.backpack.crud.columns.'.$showRow['type'])
@else
@if(view()->exists('crud::columns.'.$showRow['type']))
@include('crud::columns.'.$showRow['type'])
@else
@include('crud::columns.text')
@endif
@endif
@endif
@endforeach
</tr>
</tbody>
<tfoot><tr>
@if ( $crud->buttons->where('stack', 'line')->count() )
<th>{{ trans('backpack::crud.actions') }}</th>
@endif
</tr></tfoot>
</table>
Nice to have:
re: "That said, I'm sure everyone would appreciate a PR based on what you've suggested."
@tabacitu had suggested: _"If you do want to work on this, after we pen down the solution I could create a feature branch for you, so we can collaborate there."_
...and I was looking for that sort of explicit 'Yes, make it so' permission to help with it -- a little more formal and structured than just submitting an out-of-the-blue pull request.
https://github.com/Laravel-Backpack/CRUD/issues/226#issuecomment-301322417 all sounds good to me.
https://github.com/Laravel-Backpack/CRUD/pull/991 is a PR for this.

Thanks to @AbbyJanke this is now ready to use. composer update and just specify $this->crud->allowAccess('show'); in your EntityCrudController.
Cheers!
Most helpful comment
Thanks to @AbbyJanke this is now ready to use.
composer updateand just specify$this->crud->allowAccess('show');in your EntityCrudController.Cheers!