定制 tuytoosh/active 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

tuytoosh/active

Composer 安装命令:

composer require tuytoosh/active

包简介

Active class in blade templates

README 文档

README

Installation

For installation use this command:

composer require tuytoosh/active

Publish configuration

A simple configuration file has a config key for default active class. Use

php artisan vendor:publish --tag=config --force

in order to publish the configuration file. The config key is located in ./config/active.php file and you can replace the default value with your own. In the configuration you can change default active and inactive classes. For example you can use tailwind classes to activate or deactivate navbar menu items:

<?php

return [
    'class' => 'active',
    'inactive_class' => '',
];

How to use

With this package instead of using:

class="@if(Route::currentRouteName() == 'home') active @endif"

In blade files you can simply use:

class="@active('home')"

Override default active and inactive classes

You can override the default active class by passing second parameter to the directive like this:

class="@active('home', 'open', 'closed')"

Use * for all routes

  • class="@active('*')" will be active for all routes
  • class="@active('admin.*')" will be active for all routes that starts with admin.
  • class="@active('admin.post.*', 'open')" will be open for all routes that starts with admin.post.

Array of routes

You can pass an array of routes as first parameter to the directive like this:

class="@active(['admin.dashboard', 'user.dashboard'])"

* and exact patterns will work as well.

active() and isActive() helpers

All features are available in active() helper function. for example you can use it in your controller like this:

// returns string
$class = active('home');

or

// returns boolean
if(isActive('home')){

}

Todo

  • Add support for * at the end of route name
  • Add tests
  • Make it compatible with older versions of Laravel
  • Support for route parameters!
  • support for array of route patterns

License

MIT

Contributing

Please feel free to fork this project and make pull requests. Test env is ready to use with orchestra testbench and you just need run:

composer install
./vendor/bin/phpunit --debug --colors

tuytoosh/active 适用场景与选型建议

tuytoosh/active 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.67k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2022 年 05 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 tuytoosh/active 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.67k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-05