bfg/livewire

Finder for the Livewire

Installs: 62

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 1

Open Issues: 0

Type:bfg-app

1.4.0 2022-11-06 21:21 UTC

This package is auto-updated.

Last update: 2024-11-04 17:42:03 UTC


README

Extension for the Livewire package. Adds finder for components and extend with:

Install

composer required bfg/livewire

Usage

View

@extends('livewire::document')

@section('head')
    <title>Main</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
@endsection

@section('body')
    @yield('content')
@endsection

@section('footer')
    
@endsection

Turbolinks

Access:

window.Turbolinks.visit("/edit", { action: "replace" })

SweetAlert2

Access:

window.Swal.fire('Any fool can use a computer')

Toastr

Access:

window.Toastr.info('Are you the 6 fingered man?')

Livewire Events

Simple Swal access:

class MyComponent extends \Livewire\Component
{
    ...
    public function submit() {
        $this->emit('swal', [
            'icon' => 'error',
            'title' => 'Oops...',
            'text' => 'Something went wrong!',
            'footer' => '<a href="">Why do I have this issue?</a>'
        ]);
    }
    ...
}

Swal confirm access:

...
    $this->emit('swal:confirm', [
        'title' => 'Do you want to save the changes?',
        'text' => 'Save changes',
        'confirmEvent' => 'livewireEvent', // You livewire event
        'confirmParams' => ['user_id' => 1], // You livewire event parameters
    ]);
...

Swal message access:

...
    $this->emit('swal:success', [
        'title' => 'Changes saved!',
        'text' => 'All you changes is saved'
    ]);
    // Or
    $this->emit('swal:success', [ // Can be: success, error, warning, info 
        'Changes saved!', 
        'All you changes is saved'
    ]);
...

Toastr message access:

...
    $this->emit('toastr:success', 'Changes saved!');
    $this->emit('toastr:success', [ // Can be: success, error, warning, info 
        'Changes saved!', 
        'All you changes is saved',
        ['timeOut' => 5000]
    ]);
...

Turbolinks visit access:

...
    $this->emit('visit', '/edit');
    // Or
    $this->emit('visit', [
        '/edit', ['action' => 'replace']
    ]);
...

Extending

For inject folder you can do this:

Bfg\Livewire\LivewireComponentsFinder::directory('Admin\\Pages', __DIR__.'/../Pages');
LivewireComponentsFinder::directory(string $namespace, string $path);