Respect wrote a reply+100 XP
5d ago
ohh thanks so much now it's working my code was inside boot() did not working after i moved it to register() it's working now in both ways are working thanks so much now i can track the hook i will continues working on package thanks again
Respect wrote a reply+100 XP
6d ago
thanks for answer i tried custom class before not working something like
Livewire::componentHook(PropertySecurityHook::class);
i think the main point now global hook or listener for editing more then a month iam working in this package .. it's possible in livewire 3 global listener . but in liveiwre 4 did not working - i will trying search for more ideas . the main point realted to livewire v4
Respect wrote a reply+100 XP
6d ago
Thanks for answer i wanna share my knowlage may helping some one i need listen to it globally because i am trying to create a composer livewire package almost done the logic 97% that will secure properies by default because livewire-strict does not working any more for livewire 4 single file component --sfc so the only step left how to listen globally so that i need listen globally
Respect wrote a reply+100 XP
6d ago
thanks for answer but both of them did not work
Respect wrote a reply+100 XP
6d ago
thanks for answer - i wanna share my knowlage may helping some one i need listen to it globally because i am trying to create a composer livewire package almost done the logic 97% that will secure properies by default because livewire-strict does not working any more for livewire 4 single file component --sfc so the only step left how to listen globally so that i need listen globally if i did not find a way - i think i have to reformat it as normal code and ppl use a BaseComponent extends or Trait or something - i hope can find a way to make it a package
Respect wrote a reply+100 XP
6d ago
thanks for answer but did not working in livewire v 4 got error
Error
vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:363
Call to undefined method Livewire\LivewireManager::hook()
LARAVEL
13.3.0
PHP
8.3.30
UNHANDLED
CODE 0
500
GET
http://127.0.0.1:8000/admin/order/create
Exception trace
1 vendor frame
Illuminate\Support\Facades\Facade::__callStatic()
app/Providers/AppServiceProvider.php:34
29
34 Livewire::hook('commit', function ($component, $commit) {
35 dd('Hello from app ServiceProvider');
36 // You can inspect $commit->updates for specific property changes.
37 });
38 }
39}
- full code
<?php
use Livewire\Livewire;
public function boot(): void
{
Livewire::hook('commit', function ($component, $commit) {
dd('Hello from app ServiceProvider');
// You can inspect $commit->updates for specific property changes.
});
}
Respect wrote a reply+100 XP
6d ago
first thnaks for answer i am using livewire 4
Respect started a new conversation+100 XP
1w ago
how to listen globally to livewire updating hook from AppServiceProvider.php in boot method
- Does not work
\Livewire\Livewire::listen('component.updating', function ($component) {
// This will now catch the internal "Livewire\Generated\Component..." classes
throw new \Exception('Global Boot Caught SFC: ' );
});
Respect wrote a reply+100 XP
2w ago
oh thanks for answer , is there any alternative way ?
Respect started a new conversation+100 XP
2w ago
- hello friends thanks for helping why wire wire-elements/livewire-strict package not working in livewire v4 and is there alternative
- it's not throwing any exeption if try to update any property from client side (nothing happen like in v3)
https://github.com/wire-elements/livewire-strict
AppServiceProvider.php
<?php
namespace App\Providers;
use WireElements\LivewireStrict\LivewireStrict;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
LivewireStrict::lockProperties();
}
/**
* Bootstrap any application services.
*/
}
Respect wrote a reply+100 XP
3w ago
i need it globally no need put it in each action button need something put it inside app-blade.php
Respect started a new conversation+100 XP
3w ago
- hot to make request continue
<script>
document.addEventListener('livewire:init', () => {
Livewire.hook('component.init', ({
component
}) => {
component.intercept('delete', async ({
action
}) => {
action.cancel();
const result = await Swal.fire({
title: 'Are you sure?',
text: "This action is permanent!",
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'Cancel'
});
// 3. If confirmed, resume the action
if (result.isConfirmed) {
// how to make request continue to delete
}
})
});
});
</script>
public function delete($id)
{
$jobTitle = JobTitle::findOrFail($id)->delete();
}
Respect wrote a reply+100 XP
1mo ago
which method is better for preformance because my app is erp system 1 - using x-teleport 2 - using $disptach event for example
// on search input
x-on:input="$dispatch('search-input-change ',{value : $event.target.value})"
// in traits
#[On('search-input-change')]
public function onSearchInputChange($value)
{
$this->search = $value;
$this->resetPage();
}
Respect liked a comment+100 XP
1mo ago
This happens because of how Livewire scopes its DOM tree. When you push the search input into <x-slot name="rightSection">, Blade extracts that code and renders it outside of your Livewire component's root <div> in the app-admin.blade.php layout. Livewire only tracks and hydrates wire:model bindings that live inside its root element (which is what gets rendered in {{ $slot }}). Because the named slot is injected elsewhere in the DOM, Livewire's JavaScript simply can't see it.
Keep the input physically inside your Livewire component's default slot, but "teleport" it visually to the header.
Add an ID to the target container in your app-admin.blade.php layout:
<div id="right-section-container" class="flex justify-center items-center gap-2">
{{ $rightSection ?? '' }}
</div>
In your Livewire component, remove the search input from the <x-slot> and use <template x-teleport="..."> inside your main default slot:
<div>
<x-slot name="title">...</x-slot>
<x-slot name="breadcrumbs">...</x-slot>
<x-slot name="rightSection">
<x-buttons.create href="#" x-data="{}" x-on:click="$dispatch('open-modal', { name: 'create-job-title' })" :name="__('app.create_job_title')" />
<x-dropdowns.per-page />
</x-slot>
<template x-teleport="#right-section-container">
<x-inputs.search wire:model.live="search" />
</template>
</div>
This keeps the input inside Livewire's component state/scope while rendering it exactly where you want in the layout UI.
Respect started a new conversation+100 XP
1mo ago
- hello
Why search input inside custom slot not working when typing , if moved out the custom slot will working
// index page code & app-admin.blade.php layout code below
<?php
use App\Actions\Admin\JobTitle\JobTitleIndexAaction;
use App\Models\JobTitle;
use App\Traits\HasFilter;
use App\Traits\HasPagination;
use Livewire\Attributes\Computed;
use Livewire\Component;
new class extends Component {
use HasFilter, HasPagination;
#[Computed]
public function jobTitles()
{
return app(JobTitleIndexAaction::class)->handle(search: $this->search, sortField: $this->sortField, sortDirection: $this->sortDirection, perPage: $this->perPage);
}
};
?>
<div>
<x-slot name="title">@lang('app.job_titles')</x-slot>
<x-slot name="breadcrumbs">
<x-breadcrumbs.breadcrumb-admin-item :name="__('app.job_titles')" active />
</x-slot>
<x-slot name="leftSection">
<span class="text-2xl"> @lang('app.job_titles')
</span>
<p class="text-1 text-gray-500 dark:text-gray-200">
@lang('app.sub_titles_sub_title')
</p>
</x-slot>
<x-slot name="rightSection">
<x-buttons.create href="#" x-data="{}"
x-on:click="$dispatch('open-modal', { name: 'create-job-title' })" :name="__('app.create_job_title')" />
<x-dropdowns.per-page />
<x-inputs.search wire.model.live="search" /> // ( this not working yet ) $search exists inside HasFilter
</x-slot>
<x-inputs.search wire.model.live="search" /> // ( this working 100% ) $search exists inside HasFilter
// rest of code and tables and loops
</div>
// app-admin.blade.php code
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" dir="{{ App::getLocale() === 'ar' ? 'rtl' : 'ltr' }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" sizes="16x16" href="{{ asset('assets/images/favicon-16x16.png') }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ asset('assets/images/favicon-32x32.png') }}">
<meta name="robots" content="noindex, nofollow">
<link href="https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap" rel="stylesheet">
@vite('resources/css/admin.css')
@livewireStyles
<title>@lang('app.dashboard') | {{ $title ?? ' Dashboard' }}</title>
</head>
<body class="bg-page-bg dark:text-gray-100">
<div class="bg-bluex-100 grid x-cloak grid-cols-[1fr] lg:grid-cols-[250px_1fr] grid-rows-[60px_1fr] duration-300 ease-in-out"
x-data="{ isCollapsed: false, isMobileSidebarOpen: true }" x-bind:class="{ 'lg:!grid-cols-[90px_1fr] ': isCollapsed }">
<!-- navbar start -->
<div
class="bg-white dark:bg-dark col-start-1 col-end-3 lg:col-start-2 lg:col-end-3 py-3 px-6 border-b border-gray-200 dark:border-black flex justify-between items-center">
<div>
<x-breadcrumbs.breadcrumb-admin>
{{ $breadcrumbs ?? '' }}
</x-breadcrumbs.breadcrumb-admin>
</div>
<div>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="size-6 lg:hidden ltr:rotate-0 rtl:rotate-180"
x-on:click="isMobileSidebarOpen = true">
<path stroke-linecap="round" stroke-linejoin="round"
d="m5.25 4.5 7.5 7.5-7.5 7.5m6-15 7.5 7.5-7.5 7.5" />
</svg>
</div>
</div>
<x-sidebars.sidebar-admin-mobile />
<x-sidebars.sidebar-admin />
<!-- content start -->
<div class="p-3 col-start-1 col-end-3 lg:col-start-2 lg:col-end-3 row-start-2 row-end-3">
<div class="py-4 px-6 flex flex-col gap-5 md:gap-0 md:flex-row items-center justify-between">
<div>
<h1 class="font-bold text-xl">{{ $leftSection ?? 'default leftSection' }}</h1>
</div>
<div>
{{ $centerSection ?? '' }}
</div>
<div class="flex justify-center items-center gap-2">
{{ $rightSection ?? '' }}
</div>
</div>
<div class="bg-white dark:bg-dark py-6 m-6 border border-gray-200 dark:border-0 content-fixer">
{{ $slot }}
</div>
</div>
<x-footers.footer-admin />
</div>
@livewireScripts
@vite('resources/js/app.js')
@stack('js')
</body>
</html>
Respect wrote a reply+100 XP
1mo ago
okey thanks for clear this for me , i will use blaze partially like you said in app service provider insted of all component thanks
Respect started a new conversation+100 XP
1mo ago
- my laravel 13 livewire 4 app component <x-sidebars.sidebar-admin /> not working in my lazyout file when use blaze ( mast put the code direct inside layout file to wroking )
if disabled blaze component works
note: always aim clear:view and clear:cache
FULL CODE IS BELOW
// app-blade.php
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" dir="{{ App::getLocale() === 'ar' ? 'rtl' : 'ltr' }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" sizes="16x16" href="{{ asset('assets/images/favicon-16x16.png') }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ asset('assets/images/favicon-32x32.png') }}">
<meta name="robots" content="noindex, nofollow">
<link href="https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap" rel="stylesheet">
@vite('resources/css/admin.css')
@livewireStyles
<title>@lang('app.dashboard') | {{ $title ?? ' Dashboard' }}</title>
</head>
<body class="bg-gray-100">
<div class="bg-gray-100 grid x-cloak grid-cols-[1fr] lg:grid-cols-[250px_1fr] grid-rows-[60px_1fr] duration-300 ease-in-out"
x-data="{ isCollapsed: false, isMobileSidebarOpen: true }" x-bind:class="{ 'lg:!grid-cols-[90px_1fr] ': isCollapsed }">
<!-- navbar start -->
<!-- navbar end -->
<!-- SIDEBAR ADMIN START -->
<x-sidebars.sidebar-admin /> // this not working
<!-- SIDEBAR ADMIN END -->
<!-- content start -->
<!-- content end -->
<x-footers.footer-admin /> // this working without any problem
</div>
@livewireScripts
<script>
document.addEventListener('livewire:init', () => {
Livewire.on('alert', (event) => {
});
});
</script>
@vite('resources/js/app.js')
@stack('js')
</body>
</html>
AppServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Livewire\Blaze\Blaze;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void {}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Blaze::optimize()->in(resource_path('views/components'));
}
}
Respect wrote a reply+100 XP
5mos ago
thx for answer but i need seperate files becuase may be add some custom css with same class names no need any confliction .so that iam asking about seperating fiel btween admin and website frontend
Respect started a new conversation+100 XP
5mos ago
- hello how to make custom css and js in the app for example app.css & admin.css & app.js & admin.js ( in my laravel livewire app ) with tailwind css - becasue i need make dffrent configs in each file and override colors for example
- i have app.blade.php
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
@vite('resources/css/app.css')
@livewireStyles
</head>
<body>
{{ $slot }}
@vite('resources/js/app.js')
</body>
</html>
- i have app-admin.blade.php
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
@vite('resources/css/admin.css')
@livewireStyles
</head>
<body>
{{ $slot }}
@vite('resources/js/admin.js')
</body>
</html>
Respect wrote a reply+100 XP
5mos ago
okey ty i started with livewire 3 ty
Respect started a new conversation+100 XP
5mos ago
hello
Does to use livewire 4 now for real world project or go with livewire 3 in know it's stell in beta . but will starting new project but need features of livewire v4 like blaze and preformance and structure