JonatasBraz
JonatasBraz
Explore posts from servers
FFilament
Created by JonatasBraz on 11/18/2024 in #❓┊help
Change Bulk Action Visibility Based on Selected Row's field value
Is it possible to change Bulk Action Visiblity based on selected row's attributes? For example, i want to show "Desfazer" Bulk Action only if selected row's Fl_finalizado = true. i tried the following code, but it keeps me showing the error App\Filament\Resources\SorteioResource::App\Filament\Resources{closure}(): Argument #1 ($records) must be of type Illuminate\Support\Collection, null given.
->visible(function (Collection $records) {
// Verificando se todas as linhas selecionadas têm fl_finalizado = true
return $records->every(fn($record) => $record->fl_finalizado);
})
->visible(function (Collection $records) {
// Verificando se todas as linhas selecionadas têm fl_finalizado = true
return $records->every(fn($record) => $record->fl_finalizado);
})
also tried this to avoid the error, but the action never shows:
->visible(function (Collection $records = null) {
// Verifica se as linhas selecionadas são válidas
if ($records === null) {
return false; // Se não houver registros selecionados, retorna false
}

// Verificando se todas as linhas selecionadas têm fl_finalizado = true
return $records->every(fn($record) => $record->fl_finalizado);
})
->visible(function (Collection $records = null) {
// Verifica se as linhas selecionadas são válidas
if ($records === null) {
return false; // Se não houver registros selecionados, retorna false
}

// Verificando se todas as linhas selecionadas têm fl_finalizado = true
return $records->every(fn($record) => $record->fl_finalizado);
})
2 replies
FFilament
Created by JonatasBraz on 11/13/2024 in #❓┊help
Render a Modal after Create
Is it possible to render a modal after creating a record in CreateResource? I tried Action::make, but didn't work
<?php

namespace App\Filament\Resources\ClienteResource\Pages;

use App\Filament\Resources\ClienteResource;
use App\Models\Sorteio;
use Filament\Actions\Action;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class CreateCliente extends CreateRecord
{
protected static string $resource = ClienteResource::class;

protected function handleRecordCreation(array $data): Model
{

try {

DB::beginTransaction();
$novoCliente = static::getModel()::create($data);
$sorteios = Sorteio::disponiveis($novoCliente);

if ($sorteios) {
$arraySorteios = $sorteios->pluck('id')->toArray();
$novoCliente->sorteios()->sync($arraySorteios);
}

DB::commit();
return $novoCliente;

} catch (\Exception $e) {

DB::rollBack();
throw $e;

} catch (\Throwable $e) {

DB::rollBack();
throw $e;

}

}

protected function afterCreate(): void {
Action::make('modal')
->requiresConfirmation();
}

protected function getRedirectUrl(): string
{
return '/clientes/create';
}

/* public function __call($name, $arguments)
{
// Verifica se o método chamado é o 'handleRecordCreation' e executa ele
if ($name === 'handleRecordCreation') {
return $this->handleRecordCreation(...$arguments);
}

// Se o método não for reconhecido, lança uma exceção
throw new \BadMethodCallException("Método $name não encontrado");
}*/
}
<?php

namespace App\Filament\Resources\ClienteResource\Pages;

use App\Filament\Resources\ClienteResource;
use App\Models\Sorteio;
use Filament\Actions\Action;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class CreateCliente extends CreateRecord
{
protected static string $resource = ClienteResource::class;

protected function handleRecordCreation(array $data): Model
{

try {

DB::beginTransaction();
$novoCliente = static::getModel()::create($data);
$sorteios = Sorteio::disponiveis($novoCliente);

if ($sorteios) {
$arraySorteios = $sorteios->pluck('id')->toArray();
$novoCliente->sorteios()->sync($arraySorteios);
}

DB::commit();
return $novoCliente;

} catch (\Exception $e) {

DB::rollBack();
throw $e;

} catch (\Throwable $e) {

DB::rollBack();
throw $e;

}

}

protected function afterCreate(): void {
Action::make('modal')
->requiresConfirmation();
}

protected function getRedirectUrl(): string
{
return '/clientes/create';
}

/* public function __call($name, $arguments)
{
// Verifica se o método chamado é o 'handleRecordCreation' e executa ele
if ($name === 'handleRecordCreation') {
return $this->handleRecordCreation(...$arguments);
}

// Se o método não for reconhecido, lança uma exceção
throw new \BadMethodCallException("Método $name não encontrado");
}*/
}
4 replies
NNuxt
Created by JonatasBraz on 10/23/2024 in #❓・help
Horizontal URadioGroup
No description
4 replies
NNuxt
Created by JonatasBraz on 8/22/2024 in #❓・help
Example of Edit Dropdown
Hey'all, i'm currently looking for a UDropdown model to use in my table. the dropdown should have edit and delete options; edit should open the edit model declared on parent and delete should call delete function also on parent. I have few experience with nuxt3/composition api, how do you aproach this situations?
<UTable
:columns="columnsTipoDocumento"
:rows="tiposDocumentos"
>


<template #st_descricao-data="{ row }">

<div class="flex items-center justify-between">
<span>{{ row.st_descricao }}</span>
<edicao-dropdown/>
</div>
</template>
</UTable>


//modal
<tipo-documento @refresh-tipo-documento="refresh_tipo_documento()" v-model:form="selectedTipoDocumento" v-model:modal-state="modalTipoDocumentoState" />
<UTable
:columns="columnsTipoDocumento"
:rows="tiposDocumentos"
>


<template #st_descricao-data="{ row }">

<div class="flex items-center justify-between">
<span>{{ row.st_descricao }}</span>
<edicao-dropdown/>
</div>
</template>
</UTable>


//modal
<tipo-documento @refresh-tipo-documento="refresh_tipo_documento()" v-model:form="selectedTipoDocumento" v-model:modal-state="modalTipoDocumentoState" />
4 replies
NNuxt
Created by JonatasBraz on 8/15/2024 in #❓・help
UModal There are no focusable elements inside the <FocusTrap />
No description
34 replies
FFilament
Created by JonatasBraz on 8/9/2024 in #❓┊help
Nested Relationships data not beeing saved
No description
5 replies
FFilament
Created by JonatasBraz on 8/4/2024 in #❓┊help
Disable specific relationship operations on form
I'm tring to create a form for my table Endereco.
Endereco belongs to Cidade Cidade belongs to Estado Im am using 'cidade' relation just to load data from database in my 'estado_id' input, but i don't want to change anything about this relationship when sending the form. I tried to pass false as second argument of relationship() method, but it tried to delete the row instead of doing nothing. Here is the gist with my form: https://gist.github.com/JonatasBSM/4a4df444ad0b71c43fbb8ed703f4cc2b
4 replies
FFilament
Created by JonatasBraz on 7/29/2024 in #❓┊help
Relation Manager Not beeing Rendered
I have one week experience with filament and i created some relation managers for test, but none of them are working... Here is DocumentosRelationManager as example. My first step to create was use this command:
php artisan make:filament-relation-manager AlunoResource documentos in_entidade_id
php artisan make:filament-relation-manager AlunoResource documentos in_entidade_id
My second step was add the manager in my resource AlunoResource:
public static function getRelations(): array
{
return [
RelationManagers\DocumentosRelationManager::class
];
}
public static function getRelations(): array
{
return [
RelationManagers\DocumentosRelationManager::class
];
}
Did i miss something? It seems like is not beeing rendered att all. it does not show any error, but it does not appear on screen. Even if i change $relations variable in DocumentosRelationMager to a nonexistent one, nothing happens. Here is Gists with full code and thank you for time: https://gist.github.com/JonatasBSM/e45c64aaf0d4b2e5bc184d5211e26da0
9 replies