aliqasemzadeh/livewire-bootstrap-modal
Composer 安装命令:
composer require aliqasemzadeh/livewire-bootstrap-modal
包简介
Dynamic Laravel Livewire 3 Bootstrap modals.
README 文档
README
This package allows you to dynamically show your Laravel Livewire 3 components inside Bootstrap modals.
Warning: This package is not backward compatible with Livewire 2.
Documentation
Requirements
- Bootstrap 5 and PopperJS must be installed via npm first
npm install bootstrap npm install @popperjs/core
Installation
Require the package:
composer require aliqasemzadeh/livewire-bootstrap-modal
Add the livewire:modals component to your app layout view:
<livewire:modals/> <livewire:scripts/> <script src="{{ asset('js/app.js') }}"></script>
Require ../../vendor/aliqasemzadeh/livewire-bootstrap-modal/resources/js/modals in your app javascript file:
import('@popperjs/core'); import '../../node_modules/bootstrap/dist/js/bootstrap.bundle.min.js'; import '../../vendor/aliqasemzadeh/livewire-bootstrap-modal/resources/js/modals.js';
Usage
Modal Views
Make a Livewire component you want to show as a modal. The view for this component must use the Bootstrap modal-dialog container:
<div> <div class="modal-header"> <h5 class="modal-title">Modal title</h5> <button type="button" class="btn-close" wire:click="$dispatch('hideModal')" aria-label="Close"></button> </div> <div class="modal-body"> <p>Modal body text goes here.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" wire:click="$dispatch('hideModal')">Close</button> <button type="button" class="btn btn-primary">Save changes</button> </div> </div>
Showing Modals
Show a modal by emitting the showModal event with the component alias:
<button type="button" wire:click="$dispatch('showModal', {data: {'alias' : 'livewire.modal.user','params' :{'user':'Ali Qasemzadeh'}}})"> {{ __('Update Profile') }} </button>
Mount Parameters
Pass parameters to the component mount method after the alias:
<button type="button"wire:click="$dispatch('showModal', {data: {'alias' : 'livewire.modal.user','params' :{'user':'Ali Qasemzadeh'}}})"> {{ __('Update User #' . $user->id) }} </button>
The component mount method for the example above would look like this:
namespace App\Http\Livewire\Users; use App\Models\User; use Livewire\Component; class Update extends Component { public $user; public function mount(User $user) { $this->user = $user; } public function render() { return view('users.update'); } }
Hiding Modals
Hide the currently open modal by emitting the hideModal event:
<button type="button" wire:click="$dispatch('hideModal')"> {{ __('Close') }} </button>
Dismissing Modals
You can emit events inside your views:
<button type="button" wire:click="$dispatch('hideModal')"> {{ __('Close') }} </button>
Or inside your components, just like any normal Livewire event:
public function save() { $this->validate(); // save the record $this->dispatch('hideModal'); }
Custom modal size
Now you can have custom modal size by default we use modal-lg:
<button type="button"wire:click="$dispatch('showModal', {data: {'alias' : 'livewire.modal.user','size' :'modal-xl')"> {{ __('Show XL Modal') }} </button>
Publishing Assets
Custom View
Use your own modals view by publishing the package view:
php artisan vendor:publish --tag=livewire-bootstrap-modal:views
Now edit the view file inside resources/views/vendor/livewire-bootstrap-modal. The package will use this view to render the component.
Notes
1- You should use button or @click in main slot.
2- We are working hard on some problems, We hope fix them soon.
3- We will add some options soon.
4- wire:navigate not work (just first modal open).
aliqasemzadeh/livewire-bootstrap-modal 适用场景与选型建议
aliqasemzadeh/livewire-bootstrap-modal 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21.66k 次下载、GitHub Stars 达 45, 最近一次更新时间为 2022 年 11 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 aliqasemzadeh/livewire-bootstrap-modal 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aliqasemzadeh/livewire-bootstrap-modal 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 21.66k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 46
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-24