Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@promatik
Created July 29, 2018 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save promatik/0649a6997cc73a6febbf3b08e82927b7 to your computer and use it in GitHub Desktop.
Save promatik/0649a6997cc73a6febbf3b08e82927b7 to your computer and use it in GitHub Desktop.
Backpack CRUD Relation table
<?php
if($field['value'] == "")
return;
$crud->route = $field['route'];
?>
<div @include('crud::inc.field_wrapper_attributes') >
<h3 style="margin-top:0">{!! $field['label'] !!}</h3>
<div class="array-container form-group">
<table class="table table-bordered table-striped m-b-0">
<thead>
<tr>
@foreach( $field['columns'] as $column )
<th>
{{ __($column['label']) }}
</th>
@endforeach
<th data-orderable="false">{{ trans('backpack::crud.actions') }}</th>
</tr>
</thead>
<tbody class="table-striped">
@foreach( $field['value'] as $item)
<tr class="array-row">
@foreach( $field['columns'] as $key => $column)
<td>
{!! $item->{$column['name']} !!}
</td>
@endforeach
<td>
@include('crud::buttons.update', ['entry' => $item])
@include('crud::buttons.delete', ['entry' => $item])
</td>
</tr>
@endforeach
</tbody>
</table>
@php
// Add relation entity
$reflection = new ReflectionClass(get_class($crud->getModel()));
$classname = strtolower($reflection->getShortName());
$url = "{$crud->route}/create?$classname={$crud->entry->id}";
@endphp
<div class="array-controls btn-group m-t-10">
<a href="{{ $url }}">
<button class="btn btn-sm btn-default" type="button"><i class="fa fa-plus"></i> {{trans('backpack::crud.add')}}</button>
</a>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment