typed property $table must not be accessed before inicialization

According to Dan Harrin https://discord.com/channels/883083792112300104/956270111176679516/1191874067788202034, maybe there is something wrong in my code. To avoid flooding offtopic channel, I share the code here to ask for help and see if it's a bug or not. If so,I will open the issue on github. Anyway thanks.
Discord
Discord - A New Way to Chat with Friends & Communities
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
21 Replies
Babiute🍎🐍
Babiute🍎🐍OP12mo ago
1. I made a filament custom pageI have a filament custom. Its function is to render a livewire component:
<?php

namespace App\Filament\Gerencia\Pages\Atendimento;

use App\Enums\Policy;
use App\Models\Solicitacao;
use Filament\Pages\Page;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Facades\Auth;

class ViewRetiraUnidadeArquivamento extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-shopping-cart';

protected static string $view = 'filament.pages.atendimento.view-retira-unidade-arquivamento';

protected static ?int $navigationSort = 3;

protected static ?string $slug = 'atendimento/retirada';

public static function getNavigationLabel(): string
{
return __('Retirar unidade de arquivamento');
}

public function getTitle(): string|Htmlable
{
return __('Retirar unidade de arquivamento');
}

public static function getNavigationGroup(): ?string
{
return __('Atendimento');
}

public static function shouldRegisterNavigation(): bool
{
/** @var \App\Models\Usuario */
$auth = Auth::user();

return $auth->can(Policy::UPDATE->value, Solicitacao::class);
}

public function mount(): void
{
$this->authorize(Policy::UPDATE->value, Solicitacao::class);
}
}
<?php

namespace App\Filament\Gerencia\Pages\Atendimento;

use App\Enums\Policy;
use App\Models\Solicitacao;
use Filament\Pages\Page;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Facades\Auth;

class ViewRetiraUnidadeArquivamento extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-shopping-cart';

protected static string $view = 'filament.pages.atendimento.view-retira-unidade-arquivamento';

protected static ?int $navigationSort = 3;

protected static ?string $slug = 'atendimento/retirada';

public static function getNavigationLabel(): string
{
return __('Retirar unidade de arquivamento');
}

public function getTitle(): string|Htmlable
{
return __('Retirar unidade de arquivamento');
}

public static function getNavigationGroup(): ?string
{
return __('Atendimento');
}

public static function shouldRegisterNavigation(): bool
{
/** @var \App\Models\Usuario */
$auth = Auth::user();

return $auth->can(Policy::UPDATE->value, Solicitacao::class);
}

public function mount(): void
{
$this->authorize(Policy::UPDATE->value, Solicitacao::class);
}
}
2. the respective view:
<x-filament-panels::page>
@livewire('retira-unidade-arquivamento')
</x-filament-panels::page>
<x-filament-panels::page>
@livewire('retira-unidade-arquivamento')
</x-filament-panels::page>
ericmp
ericmp12mo ago
havent read ur question, but i recommend u to name everything in English \App\Models\Usuario just call it User, not Usuario? also Solicitacao and other stuff, i just recomend to u to use eng
Babiute🍎🐍
Babiute🍎🐍OP12mo ago
Hello man 🙂 A few days ago I decided to translate a code into English. Then the guy who came to offer help threw a bunch of sh** at me, because I made a typo in the name of a variable or something like that i dont remember anymore. I told him that I had translated the code to make it easier to helpers. Then he said to me: Don't translate. Post your code as it is. Note: regarding coding directly in English, I am not authorized. But yes, I can translate the code without any problems, but for the case in question, I think it will be irrelevant.
ericmp
ericmp12mo ago
a year ago i was in a company that wanted all in spanish. so they yelled at me cuz of that. but i didnt give a shit, i code in english, then i translate the strings to the final user to the desired language. finally, after months, they said i was right. im not saying to u what to do, just what i did (: and yeah this is not relevant to the question but relevant to code. and for the typos, just check it? idk english 100% neither 🤷‍♂️ i google to translate sometimes some words, its fine
awcodes
awcodes12mo ago
Use whatever language you want. My question is why are you using a livewire component in the blade file that is the same name as the $view property of the page. I think you’re creating a circular reference. In filament pages are livewire components.
Babiute🍎🐍
Babiute🍎🐍OP12mo ago
The livewire component has x.blade name. The filament view is named as view-x.blade.
awcodes
awcodes12mo ago
Also if you’re extending a livewire component, like a page you will want to call parent::mount() in your mount method. Ok, then the issue is in your livewire component, but you haven’t shared any code relating to the lW component that the page is trying to render.
Babiute🍎🐍
Babiute🍎🐍OP12mo ago
Its more then 2k letters.. trying to .. its posted as a file but file sux 😄
awcodes
awcodes12mo ago
Share it in a gist
Babiute🍎🐍
Babiute🍎🐍OP12mo ago
Nobody want to download it to read.. haha 1 sec
awcodes
awcodes12mo ago
If it’s. In a gist we don’t have to download anything and it’s syntax highlighted. 🙂 Just share the link. Looking for the code for this component by the way: @livewire('retira-unidade-arquivamento') I still think you’re trying to use the page component as the page’s content
Babiute🍎🐍
Babiute🍎🐍OP12mo ago
Babiute🍎🐍
Babiute🍎🐍OP12mo ago
The livewire component
Babiute🍎🐍
Babiute🍎🐍OP12mo ago
Gist
retira-unidade-arquivamento.blade,php
GitHub Gist: instantly share code, notes, and snippets.
awcodes
awcodes12mo ago
Can you share the flare link for the error? You scrolled down to quickly in the video you posted.
Babiute🍎🐍
Babiute🍎🐍OP12mo ago
sure
Babiute🍎🐍
Babiute🍎🐍OP12mo ago
Flare
Typed property App\Livewire\RetiraUnidadeArquivamento::$table must not be accessed before initialization - The error occurred at http://vmdcode01.sjes.gov.br:8083/gerencia/atendimento/retirada
awcodes
awcodes12mo ago
Ok here’s the issue. You’re trying to filter a table based on a form that isn’t initialized yet. There’s a reason that forms and filters are separate things. What you need is a table filter not a separate form. If you need to use a form you’ll have to set it up to modify the query string instead of trying to get the form state in the table.
Babiute🍎🐍
Babiute🍎🐍OP12mo ago
I'm using form coz i need somehow, apply some validation to the input. Only when the input is valid, the table data must be filled. Thx for your help man.
awcodes
awcodes12mo ago
Filters are still just forms, you should be able to apply validation to them, iirc.
Babiute🍎🐍
Babiute🍎🐍OP12mo ago
I tried it previously, but for some reason that i really dont remember, it didn't work as expected. I will try this approach again. Thank you again very much for your kindness.
Want results from more Discord servers?
Add your server