boomdraw/laravel-helpers

1.0.0 2018-12-03 16:39 UTC

This package is auto-updated.

Last update: 2024-09-11 14:53:38 UTC


README

此包允许您生成带有外观和别名的帮助类。它还提供了一些帮助命令和内置的帮助器。

安装后,您可以进行如下操作

命令

一次性运行 config:cacheroute:cacheview:cachehelpers:cache

php artisan cache:all

一次性运行 cache:clearconfig:clearroute:clearview:clearhelpers:clear

php artisan cache:clear-all

cache:clear-all 别名

php artisan clear:all

将帮助器添加到缓存中,以在不监控文件系统的情况下获取它们

php artisan helpers:cache

从缓存中移除帮助器

php artisan helpers:clear

一次性运行 ide-helper:generateide-helper:metaide-helper:models --nowrite

php artisan ide-helper:all

运行此命令之前,您应该先安装 barryvdh/laravel-ide-helperdoctrine/dbal

在您的项目中生成带有外观的辅助类

php artisan make:helper {class}

特性

路由键获取器

use BoomDraw\Helpers\Traits\RouteKeyGetter.php

将路由键设置为 id 用于 admin* 路由,其他路由则设置为 slug

服务名称获取器

use BoomDraw\Helpers\Traits\ServiceNameGetter.php

为帮助器添加 getServiceName() 方法,用于使用类名生成服务名称

表名称获取器

use BoomDraw\Helpers\Traits\TableNameGetter.php

添加 getTableName() 方法以获取模型表名称,添加 getMorphName() 方法以获取模型形态名称

帮助器

SeoHelper

添加 columns() 方法,允许快速将 meta_keywords、meta_description 和 robots 列添加到表迁移中

StrHelper

添加 betweenwbetweenutrim 方法

全局方法

str_betweenstr_wbetweenutrim

安装

Laravel

您可以通过 composer 安装此包

composer require boomdraw/laravel-helpers

您可以使用以下命令发布配置文件

php artisan vendor:publish --provider="BoomDraw\Helpers\HelpersServiceProvider" --tag="config"

发布后,config/helpers.php 配置文件 包含以下内容

return [

    /*
     * Path to generate helpers in your app folder
     */
    'path' => 'Helpers',

    /*
     * Dir for facades if you want to store them separately
     * If empty, facades will be generated in path with Facade postfix
     */
    'facade_dir' => null,

    /*
     * Key to store helpers in cache
     */
    'cache_key' => 'helpers_cache',

    /*
     * Writes services to cache automatically
     */
    'force_cache' => false,
];

待办事项

添加其他 SEO 功能

MIT 许可证 (MIT)

软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、特定用途适用性和非侵权性保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论该索赔、损害或其他责任是由于合同、侵权或其他原因引起的,无论是在软件或其使用或其他交易中产生的。