All Projects → bastinald → laravel-livewire-modals

bastinald / laravel-livewire-modals

Licence: other
Dynamic Laravel Livewire Bootstrap modals.

Programming Languages

PHP
23972 projects - #3 most used programming language
javascript
184084 projects - #8 most used programming language
Blade
752 projects

Projects that are alternatives of or similar to laravel-livewire-modals

laravel-livewire-ui
Laravel Livewire UI, Auth, & CRUD starter kit.
Stars: ✭ 92 (+46.03%)
Mutual labels:  livewire, laravel-livewire
powergrid-demo
⚡ PowerGrid fully configured in a Laravel project.
Stars: ✭ 38 (-39.68%)
Mutual labels:  livewire, laravel-livewire
x-blade-components
Laravel Blade Components ready to use
Stars: ✭ 36 (-42.86%)
Mutual labels:  livewire, livewire-component
livewire-sortablejs
A Laravel Livewire plugin that makes it easy to use Sortable.js
Stars: ✭ 68 (+7.94%)
Mutual labels:  livewire, laravel-livewire
tall-toasts
A Toast notification library for the Laravel TALL stack. You can push notifications from the backend or frontend to render customizable toasts with almost zero footprint on the published CSS/JS 🔥🚀
Stars: ✭ 296 (+369.84%)
Mutual labels:  livewire, livewire-component
Goodwork
Self hosted project management and collaboration tool powered by TALL stack
Stars: ✭ 1,730 (+2646.03%)
Mutual labels:  livewire, laravel-livewire
Dynamic walls App
🌘 The Dynamic_Walls scripts replicating macOS Mojave's dynamic wallpaper feature combined into an app
Stars: ✭ 180 (+185.71%)
Mutual labels:  dynamic
Flexml
🚀基于Litho的Android高性能动态业务容器。
Stars: ✭ 225 (+257.14%)
Mutual labels:  dynamic
Transitioner
A library for dynamic view-to-view transitions
Stars: ✭ 2,049 (+3152.38%)
Mutual labels:  dynamic
Dynamicrelu
Implementation of Dynamic ReLU on Pytorch
Stars: ✭ 170 (+169.84%)
Mutual labels:  dynamic
Signals.jl
Multi-Paradigm Dynamic Fast Functional Reactive Programming in Julia
Stars: ✭ 37 (-41.27%)
Mutual labels:  dynamic
Json Flatfile Datastore
Simple JSON flat file data store with support for typed and dynamic data.
Stars: ✭ 212 (+236.51%)
Mutual labels:  dynamic
Dalsoft.restclient
The C# REST Client - the only REST/ HTTP Client you will ever need
Stars: ✭ 185 (+193.65%)
Mutual labels:  dynamic
Victoire
Fullstack Symfony CMS: The perfect mix between a framework and a CMS
Stars: ✭ 227 (+260.32%)
Mutual labels:  dynamic
Aesthetic
[DEPRECATED]
Stars: ✭ 2,044 (+3144.44%)
Mutual labels:  dynamic
github-readme-activity-graph
A dynamically generated activity graph to show your GitHub activities of last 31 days.
Stars: ✭ 1,029 (+1533.33%)
Mutual labels:  dynamic
Dynamic Antd Theme
🌈 A simple plugin to dynamic change ant-design theme whether less or css.
Stars: ✭ 174 (+176.19%)
Mutual labels:  dynamic
Progress dialog
A light weight library to easily manage a progress dialog with simple steps whenever you need to do it. You can easily show and hide it.
Stars: ✭ 196 (+211.11%)
Mutual labels:  dynamic
rainbow-bash-prompt
Make your bash prompt dynamically and randomly rainbow
Stars: ✭ 49 (-22.22%)
Mutual labels:  dynamic
Wallpapper
💻 Console application for creating dynamic wallpapers for macOS Mojave and newer
Stars: ✭ 2,533 (+3920.63%)
Mutual labels:  dynamic

Laravel Livewire Modals

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

Documentation

Requirements

  • Bootstrap 5 must be installed via webpack first

Installation

Require the package:

composer require bastinald/laravel-livewire-modals

Add the livewire:modals component to your app layout view:

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

Require ../../vendor/bastinald/laravel-livewire-modals/resources/js/modals in your app javascript file:

require('@popperjs/core');
require('bootstrap');
require('../../vendor/bastinald/laravel-livewire-modals/resources/js/modals');

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>

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>

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=laravel-livewire-modals:views

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].