PHP code example of jacklove315 / modal

1. Go to this page and download the library: Download jacklove315/modal library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jacklove315 / modal example snippets


/*
|--------------------------------------------------------------------------
| Modal Component Defaults
|--------------------------------------------------------------------------
|
| Configure the default properties for a modal component.
|
| Supported modal_size;
| 'sm', 'md', 'lg'
*/
return [
    'component_defaults' => [
        'close_modal_on_click_away' => true,
        'close_modal_on_escape'     => false,
        'modal_size'                => 'md'
    ]
];

@livewire('jl-modal')



namespace App\Http\Livewire;

use Jacklove315\Modal\ModalComponent;

class DeleteOrganisationModal extends ModalComponent
{
    public function render()
    {
        return view('livewire.delete-organisation');
    }
}

public static function closeModalOnClickAway(): bool
{
    return config('jl-modal.component_defaults.close_modal_on_click_away', true);
}

public static function closeModalOnEscape(): bool
{
    return config('jl-modal.component_defaults.close_modal_on_escape', false);
}

public static function modalSize(): string
{
    return config('jl-modal.component_defaults.modal_size', 'md');
}

Livewire::component('delete-organisation-modal', DeleteOrganisationModal::class);

<button wire:click="$emit('open-modal', 'delete-organisation-modal', $data)">
    Open modal
</button>



namespace App\Http\Livewire;

use Jacklove315\Modal\ModalComponent;

class DeleteOrganisationModal extends ModalComponent
{
    public function render()
    {
        return view('livewire.delete-organisation-modal');
    }

    public function submitForm()
    {
        $this->closeModal();
    }
}
shell
php artisan vendor:publish