Laravel 8 Livewire обновляет данные после щелчка | события модели

Я пытаюсь создать простое представление списка таблиц с компонентами laravel и livewire. Я могу показать компонент, но когда я запускаю событие (изменение, модель проводки, щелчок), набор данных не обновляется, например, у меня есть вводимый текст для фильтрации моей таблицы, когда я пишу на входе, запрос запускается и компонент получает это не компонент, ни повторный рендеринг с новой информацией

это мой полный взгляд

<header class="header py-6">

    <div class="flex justify-between">
        
        <h2 class="font-bold text-2xl text-blue-dark leading-tight">
            {{ __('messages.Seizures') }}
        </h2>
        
        <div class="flex items-end">
            <div class="cursor-pointer"> 
                <i class="fas fa-plus-circle text-blue-light text-3xl"></i>
            </div>
            <div class="pl-8 flex items-center">
                    <i class="fas fa-filter text-blue-light text-lg"></i>
                    <input type="text" name="search" id="search-seizure" class="border border-blue-light rounded-full h-8 ml-1 px-4 text-blue-light" wire:model="filter">
            </div>
            <div class="pl-8 cursor-pointer" wire:click.prevent="toggleTrash()">
                @if( $trash )
                    <i class="fas fa-trash text-blue-light text-xl"></i><i class="fas fa-toggle-on text-blue-light text-xl"></i>
                @else
                    <i class="fas fa-trash text-gray-400 text-xl"></i><i class="fas fa-toggle-off text-xl text-gray-400"></i>
                @endif
            </div>
        </div>
    </div>
</header>
    
    <div class="seizure-page">
        <table class="table">
        <thead>
            <tr>
                <th>@sortablelink('date', __('messages.Date'), [], ['class' => 'pr-2'])</th>
                <th>{{ __('messages.Duration') }}</th>
                <th>@sortablelink('location', __('messages.Location'), [], ['class' => 'pr-2'])</th>
                <th>{{ __('messages.Notes') }}</th>
                <th width="100px" class="text-right">{{ __('messages.Actions') }}</th>
            </tr>
        </thead>

        <tbody>
            @foreach($seizures as $seizure)
            <tr class="cursor-pointer">
                <td>{{ $seizure->date }}</td>
                <td class="w-64">{{ $seizure->duration }}</td>
                <td>{{ $seizure->location }}</td>
                <td class="truncate-cell">{{ $seizure->note }} </td>
                <td class="end">
                    <div class="flex justify-end">
                        <button wire:click="" class="btn btn-danger btn-sm px-1"><i class="fas fa-info"></i></button>
                        <button wire:click="edit({{ $seizure }})" class="btn btn-primary btn-sm px-1"><i class="fas fa-pen"></i></button>
                        <button wire:click="delete({{ $seizure }})" class="btn btn-danger btn-sm px-1"><i class="fas fa-trash text-warm-red"></i></button>
                    </div>
                </td>
            </tr>
            @endforeach
        </tbody>

    </table>
    <div class="flex justify-center pt-4">
        {{ $seizures->links('vendor.pagination.neurons-unchained') }}
    </div>
</div>

И это компонентная логика

<?php

namespace App\Http\Livewire;

use Livewire\Component;
use App\Models\Seizure;
use Carbon\Carbon;
use Livewire\WithPagination;

class Seizures extends Component
{

    use WithPagination;

    public $trash = false;
    public $filter;
    
    public function render()
    {

        //TODO: Get paginate number from user settings
        $seizures = Seizure::sortable(['date' => 'desc'])
            ->whereNull('deleted_at')
            ->where('note', 'like', '%' . $this->filter . '%')
            ->paginate(10);
            
        if( $this->trash) {
            $seizures = Seizure::sortable(['date' => 'desc'])
            ->whereNotNull('deleted_at')
            ->where('note', 'like', '%' . $this->filter . '%')
            ->paginate(10);
        }

        return view('livewire.seizure.index')
            ->with('seizures', $seizures->appends(\Request::except('page')))
            ->layout('layouts.dashboard');
    }

    public function delete(Seizure $seizure) {
        $seizure->deleted_at = Carbon::now();
        $seizure->save();

        $this->gotoPage(1);
    }

    public function toggleTrash () {
        $this->trash = !$this->trash;
    }
}

Кнопка переключения для отображения элементов в корзине имеет ту же проблему.

Большое спасибо


person Enrique Barrero Ligero    schedule 14.11.2020    source источник
comment
та же проблема, что и здесь stackoverflow.com/questions/60395647/   -  person Enrique Barrero Ligero    schedule 15.11.2020
comment
Вам нужно указать элементы в вашем цикле. См. stackoverflow.com/questions/64817742/   -  person Qirel    schedule 15.11.2020