PHP code example of itstructure / laravel-detail-view
1. Go to this page and download the library: Download itstructure/laravel-detail-view library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
itstructure / laravel-detail-view example snippets
@detailView([
'model' => $model,
'rowFields' => [
[
'label' => 'First Name', // Row label.
'attribute' => 'first_name', // Attribute, by which the row data will be taken from a model.
],
[
'label' => 'Last Name',
'value' => function ($model) {
return $model->last_name;
}
],
]
])
@php
$detailData = [
'model' => $model,
'title' => 'Detail title', // It can be empty ''
'htmlAttributes' => [
'class' => 'table table-bordered table-striped'
],
'captionColumnConfig' => [
'label' => 'Custom title column',
'htmlAttributes' => [
'class' => 'th-title-class'
]
],
'valueColumnConfig' => [
'label' => 'Custom value column',
'htmlAttributes' => [
'class' => 'th-value-class'
]
],
'rowFields' => [
[
'attribute' => 'id', // REQUIRED if value is not defined. Attribute name to get row model data.
'label' => 'ID', // Row label.
'htmlAttributes' => [
'class' => 'tr-class'
]
],
[
'label' => 'Active', // Row label.
'value' => function ($model) { // You can set 'value' as a callback function to get a row data value dynamically.
return '<span class="icon fas '.($model->active == 1 ? 'fa-check' : 'fa-times').'"></span>';
},
'format' => 'html', // To render row content without lossless of html tags, set 'html' formatter.
],
[
'label' => 'Url link', // Row label.
'attribute' => 'url', // REQUIRED if value is not defined. Attribute name to get row model data.
'format' => [ // Set special formatter. $model->{$this->attribute} will be inserted in to 'href' attribute of <a> tag.
'class' => Itstructure\DetailView\Formatters\UrlFormatter::class, // REQUIRED. For this case it is necessary to set 'class'.
'title' => 'Source', // title between a tags.
'htmlAttributes' => [ // Html attributes for <a> tag.
'target' => '_blank'
]
]
],
[
'label' => 'Icon', // Row label.
'value' => function ($model) { // You can set 'value' as a callback function to get a row data value dynamically.
return $model->icon;
},
'format' => [ // Set special formatter. If $model->icon value is a url to image, it will be inserted in to 'src' attribute of <img> tag.
'class' => Itstructure\DetailView\Formatters\ImageFormatter::class, // REQUIRED. For this case it is necessary to set 'class'.
'htmlAttributes' => [ // Html attributes for <img> tag.
'width' => '100'
]
]
],
'created_at', // Simple row setting by string.
]
];
@endphp
@detailView($detailData)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.