承接 smirltech/livewire-modals 相关项目开发

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

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

smirltech/livewire-modals

Composer 安装命令:

composer require smirltech/livewire-modals

包简介

Dynamic Laravel Livewire Bootstrap modals.

README 文档

README

Livewire Charts

Livewire Modals

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package allows you to dynamically show your Laravel Livewire components inside Bootstrap modals.

Documentation

Requirements

Install Bootstrap 5 and Popper.js 2 in your app. See the Bootstrap 5 docs for more information.

npm install bootstrap @popperjs/core

Require bootstrap and popper.js packages in your app javascript file. Then import the Modal class from bootstrap and add it to the window object.

Using mix

require('@popperjs/core');
require('bootstrap');

import {Modal} from 'bootstrap';

window.Modal = Modal;

Using vite

import('@popperjs/core');
import('bootstrap');

import {Modal} from 'bootstrap';

window.Modal = Modal;

Installation

Require the package:

composer require smirltech/livewire-modals

Add livewire:modals and x-modals::scripts components to your layout:

<livewire:modals/>
<livewire:scripts/>
<script src="{{ asset('js/app.js') }}"></script>
<x-modals::scripts/>

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 class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <h5 class="modal-title">Modal title</h5>
            <button type="button" class="btn-close" data-bs-dismiss="modal" 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" data-bs-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Save changes</button>
        </div>
    </div>
</div>

Alternatively, you can use the x-modals::base or x-modals::form component:

<x-modals::base title="Modal title">
    Modal body text goes here.
</x-modals::base>

Showing Modals

Show a modal by emitting the showModal event with the component alias:

<button type="button" wire:click="$emit('showModal', 'auth.profile-update')">
    {{ __('Update Profile') }}
</button>

Outside of Livewire components, you can use the Livewire.emit method:

<button type="button" onclick="showModal('auth.profile-update')">
    {{ __('Update Profile') }}
</button>

or

<script>
    Livewire.emit('showModal', 'auth.profile-update');
</script>

Mount Parameters

Pass parameters to the component mount method after the alias:

<button type="button" wire:click="$emit('showModal', 'users.update', '{{ $user->id }}')">
    {{ __('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="$emit('hideModal')">
    {{ __('Close') }}
</button>

Or by using the Bootstrap data-bs-dismiss attribute:

<button type="button" data-bs-dismiss="modal">
    {{ __('Close') }}
</button>

Emitting Events

You can emit events inside your views:

<button type="button" wire:click="$emit('hideModal')">
    {{ __('Close') }}
</button>

Or inside your components, just like any normal Livewire event:

public function save()
{
    $this->validate();

    // save the record

    $this->emit('hideModal');
}

Publishing Assets

Custom View

Use your own modals view by publishing the package view:

php artisan vendor:publish --tag=livewire-modals:views

Now edit the view file inside resources/views/vendor/livewire-modals. The package will use this view to render the component.

smirltech/livewire-modals 适用场景与选型建议

smirltech/livewire-modals 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.3k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 smirltech/livewire-modals 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 3.3k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 20
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 30
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-19