Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add show view #308

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
composer.lock
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"livecontrol/eloquent-datatable": "^0.1.5",
"doctrine/dbal": "^2.5",
"venturecraft/revisionable": "1.*",
"intervention/image": "^2.3"
"intervention/image": "^2.3",
"andreasindal/laravel-markdown": "^1.1"
},
"require-dev": {
"phpunit/phpunit" : "4.*",
Expand Down
101 changes: 76 additions & 25 deletions src/resources/views/show.blade.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,85 @@
@extends('backpack::layout')

@section('content-header')
<section class="content-header">
<h1>
{{ trans('backpack::crud.preview') }} <span class="text-lowercase">{{ $crud->entity_name }}</span>
</h1>
<ol class="breadcrumb">
<li><a href="{{ url(config('backpack.base.route_prefix'), 'dashboard') }}">{{ trans('backpack::crud.admin') }}</a></li>
<li><a href="{{ url($crud->route) }}" class="text-capitalize">{{ $crud->entity_name_plural }}</a></li>
<li class="active">{{ trans('backpack::crud.preview') }}</li>
</ol>
</section>
<section class="content-header">
<h1>
{{ trans('backpack::crud.preview') }} <span class="text-lowercase">{{ $crud->entity_name }}</span>
</h1>
<ol class="breadcrumb">
<li><a href="{{ url(config('backpack.base.route_prefix'), 'dashboard') }}">{{ trans('backpack::crud.admin') }}</a></li>
<li><a href="{{ url($crud->route) }}" class="text-capitalize">{{ $crud->entity_name_plural }}</a></li>
<li class="active">{{ trans('backpack::crud.preview') }}</li>
</ol>
</section>
@endsection

@section('content')
@if ($crud->hasAccess('list'))
<a href="{{ url($crud->route) }}"><i class="fa fa-angle-double-left"></i> {{ trans('backpack::crud.back_to_all') }} <span class="text-lowercase">{{ $crud->entity_name_plural }}</span></a><br><br>
@endif
@if ($crud->hasAccess('list'))
<a href="{{ url($crud->route) }}"><i class="fa fa-angle-double-left"></i> {{ trans('backpack::crud.back_to_all') }} <span class="text-lowercase">{{ $crud->entity_name_plural }}</span></a><br><br>
@endif

<!-- Default box -->
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">
{{ trans('backpack::crud.preview') }}
<span class="text-lowercase">{{ $crud->entity_name }}</span>
</h3>
</div>
<div class="box-body">
{{ dump($entry) }}
</div><!-- /.box-body -->
</div><!-- /.box -->
<h1>PACKAGE VIEW</h1>

<!-- Default box -->
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">
{{ trans('backpack::crud.preview') }}
<span class="text-lowercase">{{ $crud->entity_name }}</span>
</h3>
</div>
<div class="box-body">
@php($fields = $crud->getFields('both'))
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Fields</th>
<th>Values</th>
</tr>
</thead>
@foreach($entry->getCasts() as $property => $type)
<tr>
<td>
@if(array_key_exists($property, $fields))
{{ $fields[$property]['label'] }}
@else
{{ strtoupper($property) }}
@endif
</td>

@if(in_array($type, ['int', 'integer', 'real', 'float', 'double']))
@if($property !== 'id' && array_key_exists('entity', $fields[$property]))
@php($entity = $fields[$property]['entity'])
@php($attribute = $fields[$property]['attribute'])
<td>{{ $entry->$entity->$attribute }}</td>
@else
<td>{{ $entry->$property }}</td>
@endif
@elseif($type === 'string')
@if($fields[$property]['type'] === 'simplemde')
<td>@markdown($entry->$property)</td>
@elseif(in_array($fields[$property]['type'], ['ckeditor', 'summernote', 'tinymce', 'wysiwyg']))
<td>{!! $entry->$property !!}</td>
@else
<td>{{ $entry->$property }}</td>
@endif
@elseif($type === 'boolean')
<td>
<span class="badge label-{{ $entry->$property ? 'success' : 'danger' }}">
{{ $entry->$property }}
</span>
</td>
@elseif($type === 'object')
{{--TODO--}}
@elseif($type === 'array' || $type === 'collection')
{{--TODO--}}
@elseif($type === 'date' || $type === 'datetime' || $type === 'timestamp')
<td>{{ date('Y-m-d H:i:s', strtotime($entry->$property)) }}</td>
@endif
</tr>
@endforeach
</table>
</div><!-- /.box-body -->
</div><!-- /.box -->

@endsection