承接 itstructure/laravel-detail-view 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

itstructure/laravel-detail-view

Composer 安装命令:

composer require itstructure/laravel-detail-view

包简介

Detail view table for laravel framework

README 文档

README

Latest Stable Version Latest Unstable Version License Total Downloads Build Status Scrutinizer Code Quality

Introduction

This package is to displaying the model data in a Detail table.

Detail view appearance

Requirements

  • laravel 5.5+ | 6+ | 7+ | 8+ | 9+ | 10+ | 11+ | 12+ | 13+
  • php >= 7.1
  • composer

Installation

General from remote packagist repository

Run the composer command:

composer require itstructure/laravel-detail-view "~1.0.8"

If you are testing this package from a local server directory

In application composer.json file set the repository, as in example:

"repositories": [
    {
        "type": "path",
        "url": "../laravel-detail-view",
        "options": {
            "symlink": true
        }
    }
],

Here,

../laravel-detail-view - directory path, which has the same directory level as application and contains Detail View package.

Then run command:

composer require itstructure/laravel-detail-view:dev-main --prefer-source

Publish files (Not necessary)

  • To publish views run command:

    php artisan detail_view:publish --only=views

    It stores view files to resources/views/vendor/detail_view folder.

  • To publish translations run command:

    php artisan detail_view:publish --only=lang

    It stores translation files to resources/lang/vendor/detail_view folder.

  • To publish all parts run command without only argument:

    php artisan detail_view:publish

    Else you can use --force argument to rewrite already published files.

Else you can use --force argument to rewrite already published file.

Usage

View template part

Use @detailView() directive with config array in a blade view template.

Simple quick usage

You can simply set rows to display as string format in rowFields array.

Note: $model must be instance of Illuminate\Database\Eloquent\Model.

@php
$detailData = [
    'model' => $model,
    'title' => 'Detail table',
    'rowFields' => [
        'id',
        'active',
        'icon',
        'created_at'
    ]
];
@endphp
@detailView($detailData)

Alternative variant without a blade directive:

{!! detail_view([
    'model' => $model,
    'title' => 'Detail table',
    'rowFields' => [
        'id',
        'active',
        'icon',
        'created_at'
    ]
]) !!}

Setting custom options

Rows

Simple example:

@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;
            }
        ],
    ]
])
Formatters

There are the next formatter keys:

  • html - is for passing a row content with html tags.
  • image - is for inserting a row data in to src attribute of <img> tag.
  • text - applies strip_tags() for a row data.
  • url - is for inserting a row data in to href attribute of <a> tag.

For that keys there are the next formatters:

  • HtmlFormatter
  • ImageFormatter
  • TextFormatter
  • UrlFormatter

Also you can set formatter with some addition options. See the next simple example:

@detailView([
    'model' => $model,
    'rowFields' => [
        [
            'attribute' => 'url',
            'format' => [
                'class' => Itstructure\DetailView\Formatters\UrlFormatter::class,
                'title' => 'Source',
                'htmlAttributes' => [
                    'target' => '_blank'
                ]
            ]
        ],
        [
            'attribute' => 'content',
            'format' => 'html'
        ]
    ]
])
Table heads

To set column titles, you can set captionColumnConfig and valueColumnConfig as in example:

@detailView([
    'model' => $model,
    'captionColumnConfig' => [
        'label' => 'Custom title column',
        'htmlAttributes' => [
            'class' => 'th-title-class'
        ]
    ],
    'valueColumnConfig' => [
        'label' => 'Custom value column',
        'htmlAttributes' => [
            'class' => 'th-value-class'
        ]
    ],
    'rowFields' => [
        [
            'attribute' => 'content',
        ]
    ]
])

To hide all table row with head titles:

@detailView([
    'model' => $model,
    'showHead' => false,
    'rowFields' => [
        [
            'attribute' => 'content',
        ]
    ]
])
Complex extended example
@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)

License

Copyright © 2021-2026 Andrey Girnik girnikandrey@gmail.com.

Licensed under the MIT license. See LICENSE.txt for details.

itstructure/laravel-detail-view 适用场景与选型建议

itstructure/laravel-detail-view 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.78k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「view」 「laravel」 「table」 「detail」 「detailview」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 itstructure/laravel-detail-view 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 itstructure/laravel-detail-view 我们能提供哪些服务?
定制开发 / 二次开发

基于 itstructure/laravel-detail-view 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 6.78k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-04-24