Ivan
Table Builder update data using Livewire 3
I am trying to update the information of a Table, from another table doing a dispatch the information arrives correctly to showCollegeList, but the resetTable is not done, that is to say, the query is not updated. <?php
namespace App\Livewire\Insights;
use App\Models\CollegeList as CollegeListModel;
use App\Traits\CollegeTrait;
use App\Traits\MyListTrait;
use App\Traits\NotificationTrait;
use Archilex\AdvancedTables\AdvancedTables;
use Archilex\AdvancedTables\Livewire\Page;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Tables\Actions\Action;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
class CollegeList extends Page implements HasForms
{
use AdvancedTables, InteractsWithForms, NotificationTrait, MyListTrait, CollegeTrait;
public $list;
public $list_id;
protected $listeners = ['showCollegeList'];
public function showCollegeList($list_id)
{
$user = Auth::user();
$this->list_id = $list_id;
$this->list = $this->getMyList($user->id, $list_id);
$this->resetTable();
}
public function table(Table $table): Table
{
return $table
->query(CollegeListModel::query()->where('list_id', $this->list_id)->with('colleges'))
->columns([
TextColumn::make('colleges.name')->label('Name'),
])
->emptyStateHeading('No College Lists yet')
->emptyStateDescription('Once you create your first list, it will appear here.')
->emptyStateActions([
Action::make('create')
->label('Add new list')
->icon('heroicon-m-plus')
->button()->action(function ($livewire, $record) {
$this->openModal();
})
]);
}
2 replies