astrogoat/promobar
Composer 安装命令:
composer require astrogoat/promobar
包简介
A Promobar app for Strata
关键字:
README 文档
README
Installation
You can install the package via composer:
composer require astrogoat/promobar
Usage
Include the Blade component where you would like it to appear when ever the promobar bar has been enabled via the app settings.
<x-promobar::show />
Since it's a Blade component you can also add any attributes you might need.
<x-promobar::show class="sticky top-0" />
Extending
You can extend the promobar to use your own settings and render if you have special needs.
Three files are needed in order to extend it.
- A type class that extends
Astrogoat\Promobar\Types\PromobarType. - Two Blade files
- One for the settings view
- And one for the user-facing side, that will be on your site.
Let's start with the type class. Create a new class and extend Astrogoat\Promobar\Types\PromobarType.
The class only require two methods. renderSettings and renderComponent which needs to be the string path to your two Blade files.
<?php namespace App\Promobar\Types; use Astrogoat\Promobar\Types\PromobarType; class PopupType extends PromobarType { public function renderSettings() : string { return 'promobar.settings'; } public function renderComponent() : string { return 'promobar.component'; } }
Let's create those two Blade files.
resources/views/promobar/settings.blade.php
Here is where you can define what you settings will look like when you go to Apps -> Promobar and select your promobar type. Though we haven't hooked it up, so nothing will show up just yet.
<div> <input name="payload[content_desktop]" wire:model="payload.content_desktop" /> <input name="payload[content_mobile]" wire:model="payload.content_mobile" /> </div>
Important: When you add any type of inputs that you want to be persisted you need to add the
nameandwire:modelattributes. Name has to be a html array starting withpayload[]. What you put inside the brackes it what ever name you want it to be called. Same goes for thewire:model, it has to start withpayload., again what ever you put after the.(dot) is up to your, but should be the same as yournameattribute.
Now in your component Blade view (what's going to be the user-facing component) you can make use of the inputs that you defined in the settings Blade file.
resources/views/promobar/component.blade.php
<div>
<span class="md:hidden">{{ $payload['content_mobile'] ?? '' }}</span>
<span class="hidden md:flex">{{ $payload['content_desktop'] ?? '' }}</span>
</div>
Final step is to hook it up.
In your service provider in the register method you can hook into the promobar.
The $promobar->addType() method require two arguments. First is the key, in this case we call it popup and second argument is the type class that we created earlier.
use App\Promobar\Types\PopupType; $this->callAfterResolving('Astrogoat\\Promobar\\Promobar', function ($promobar) { $promobar->addType(key: 'popup', type: PopupType::class); });
Real world example
You can see a real world example on how the Zaius app hooks into the promobar.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
This promobar package is forked from the awesome Spatie promobar package. Please go support them if you can.
License
The MIT License (MIT). Please see License File for more information.
astrogoat/promobar 适用场景与选型建议
astrogoat/promobar 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 14.94k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 11 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「astrogoat」 「promobar」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 astrogoat/promobar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 astrogoat/promobar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 astrogoat/promobar 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
统计信息
- 总下载量: 14.94k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-11-03