Marco Mapelli
Marco Mapelli
Explore posts from servers
TLCTuto's Laravel Corner
Created by Marco Mapelli on 6/11/2024 in #💡filament
TAB pagination reset
My problem is that opening from a table a modal window that contains tabs, when I click on a tab the page of the table is reset. How do I avoid this?
5 replies
FFilament
Created by Marco Mapelli on 6/10/2024 in #❓┊help
Pagination and modal with tabs
I have a custom page where I display a table with an image. When I click on the image, a modal opens with tabs inside. In the list resource, I created:
public function setPage($page, $pageName = 'page')
{
parent::setPage($page, $pageName);
$this->dispatch('scroll-to-top');
}
public function setPage($page, $pageName = 'page')
{
parent::setPage($page, $pageName);
$this->dispatch('scroll-to-top');
}
The problem is that clicking on the tabs is interpreted as pagination, so the $this->dispatch('scroll-to-top'); is executed. How can I fix this?
3 replies
FFilament
Created by Marco Mapelli on 4/22/2024 in #❓┊help
Action in footer table
Hello, is it possible to insert an action in the footer of the table (getFooterActions ??)? I need to create a button that, once I have finished scrolling through the entire table, can redirect me to another page. Now i have this in List.. resource:
protected function getHeaderActions(): array
{
return [
Action::make('showroom')
->label(__('b2brstoys.showroom.torna_a_showroom'))
->color('success')
// ->action(function () {
// return redirect(ShowroomResource::getUrl('index'));
// }),
->url(fn (): string => ShowroommarcheResource::getUrl()),
];
}
protected function getHeaderActions(): array
{
return [
Action::make('showroom')
->label(__('b2brstoys.showroom.torna_a_showroom'))
->color('success')
// ->action(function () {
// return redirect(ShowroomResource::getUrl('index'));
// }),
->url(fn (): string => ShowroommarcheResource::getUrl()),
];
}
3 replies
FFilament
Created by Marco Mapelli on 4/5/2024 in #❓┊help
HELP getGlobalSearchResults
No description
7 replies
TLCTuto's Laravel Corner
Created by Marco Mapelli on 2/16/2024 in #💡filament
Classification filament plugin ??!!
Hi, I would need your opinion on a plugin that I would like to create for filament. I wanted to organize the classification of the contacts model . I wanted to create a classification_types table with the following fields: id name label is_single color icon In this table, I would include, for example, client, supplier, lead, reliable, unreliable, expensive, producer, importer... In a second table, classification_relationships, I would define the various relationships that can exist between the classification_types. It could have the following fields: id classification_id_a classification_id_b sort To assign the various classifications that the contacts can have, I would create a third table contact_classification with: contact_id classification_relationship_id default sort What do you think about it? Should I consider anything else, perhaps also thinking of using existing plugins like Select Tree? Thanks
2 replies
FFilament
Created by Marco Mapelli on 2/6/2024 in #❓┊help
Enum color in DB
What is the best way to save the colors of an enum in the db, so that the administrator can change the color?
...
public function getColor(): string|array|null
{
return match ($this) {
self::Ordinato => Color::Cyan,
self::Eseguito => Color::Blue,
self::Verificato => Color::Yellow,
};
}
...
public function getColor(): string|array|null
{
return match ($this) {
self::Ordinato => Color::Cyan,
self::Eseguito => Color::Blue,
self::Verificato => Color::Yellow,
};
}
class Color extends Model
{
protected $table = 'colors';
protected $fillable = ['name', 'value'];
}
...
public function getColor(): string|array|null
{
return match ($this) {
self::Ordinato => Color::where('name', self::Ordinato)->first()->value,
self::Eseguito => Color::where('name', self::Eseguito)->first()->value,
self::Verificato => Color::where('name', self::Verificato)->first()->value,
};
}
class Color extends Model
{
protected $table = 'colors';
protected $fillable = ['name', 'value'];
}
...
public function getColor(): string|array|null
{
return match ($this) {
self::Ordinato => Color::where('name', self::Ordinato)->first()->value,
self::Eseguito => Color::where('name', self::Eseguito)->first()->value,
self::Verificato => Color::where('name', self::Verificato)->first()->value,
};
}
6 replies
FFilament
Created by Marco Mapelli on 12/13/2023 in #❓┊help
TextInput numeric with step
I have the following code:
TextInput::make('qta')
->numeric()
->step(96)
TextInput::make('qta')
->numeric()
->step(96)
Why do I only validate multiples of 96? I i insert 24 message: the value... from 0 to 96
3 replies
FFilament
Created by Marco Mapelli on 12/4/2023 in #❓┊help
Active Tab in modal
I’m creating a new component. I have to display an image and clicking on it I have to open a modal window with a tab to create a gallery. I can’t get tab1 to open by default
...<x-filament::tabs>
<x-filament::tabs.item alpine-active="$wire.activeTab == '1'"
wire:click="$set('activeTab', '1')">
1
</x-filament::tabs.item>
@php
$conta = 2;
@endphp
@foreach ($getRecord()->articoli->foto as $image)
@if ($image->is_default == false)
<x-filament::tabs.item alpine-active="$wire.activeTab == '{{ $conta }}'"
wire:click="$set('activeTab', '{{ $conta }}')">
{{ $conta }}
</x-filament::tabs.item>
@php
$conta = $conta + 1;
@endphp
@endif
@endforeach
</x-filament::tabs>
<div x-show="$wire.activeTab == '1'">
<img id="{{ $getRecord()->articoli->foto[0]->filename }}"
src="{{ asset(Storage::url('article_images/' . $getRecord()->articoli->codart . '/' . $getRecord()->articoli->foto[0]->filename)) }}"
alt="{{ $getRecord()->articoli->foto[0]->filename }}">
</div>
@php
$conta = 2;
@endphp
@foreach ($getRecord()->articoli->foto as $image)
@if ($image->is_default == false)
<div x-show="$wire.activeTab == '{{ $conta }}' ">
<img id="{{ $image->filename }}"
src="{{ asset(Storage::url('article_images/' . $getRecord()->articoli->codart . '/' . $image->filename)) }}"
alt="{{ $image->filename }}">
</div>
@php
$conta = $conta + 1;
@endphp
@endif
@endforeach
</x-filament::modal>
...<x-filament::tabs>
<x-filament::tabs.item alpine-active="$wire.activeTab == '1'"
wire:click="$set('activeTab', '1')">
1
</x-filament::tabs.item>
@php
$conta = 2;
@endphp
@foreach ($getRecord()->articoli->foto as $image)
@if ($image->is_default == false)
<x-filament::tabs.item alpine-active="$wire.activeTab == '{{ $conta }}'"
wire:click="$set('activeTab', '{{ $conta }}')">
{{ $conta }}
</x-filament::tabs.item>
@php
$conta = $conta + 1;
@endphp
@endif
@endforeach
</x-filament::tabs>
<div x-show="$wire.activeTab == '1'">
<img id="{{ $getRecord()->articoli->foto[0]->filename }}"
src="{{ asset(Storage::url('article_images/' . $getRecord()->articoli->codart . '/' . $getRecord()->articoli->foto[0]->filename)) }}"
alt="{{ $getRecord()->articoli->foto[0]->filename }}">
</div>
@php
$conta = 2;
@endphp
@foreach ($getRecord()->articoli->foto as $image)
@if ($image->is_default == false)
<div x-show="$wire.activeTab == '{{ $conta }}' ">
<img id="{{ $image->filename }}"
src="{{ asset(Storage::url('article_images/' . $getRecord()->articoli->codart . '/' . $image->filename)) }}"
alt="{{ $image->filename }}">
</div>
@php
$conta = $conta + 1;
@endphp
@endif
@endforeach
</x-filament::modal>
3 replies
FFilament
Created by Marco Mapelli on 11/16/2023 in #❓┊help
Resize section aside heading and description
No description
7 replies
FFilament
Created by Marco Mapelli on 11/15/2023 in #❓┊help
disable field dynamically but save it in db
Hi, I need to dynamically disable a Togglebut I have to save the field: how come it doesn’t work ?
...
switch ($tipo) {
case SoggettoTipo::Contraente:
$is_contraente = true;
$is_contraente_disabled = true;
break;
case SoggettoTipo::DlDecRup:
$is_dldecrup = true;
$is_dldecrup_disabled = true;
break;
}
...
Toggle::make('is_contraente')
->default($is_contraente)
->dehydrated()
->disabled($is_contraente_disabled),
...
switch ($tipo) {
case SoggettoTipo::Contraente:
$is_contraente = true;
$is_contraente_disabled = true;
break;
case SoggettoTipo::DlDecRup:
$is_dldecrup = true;
$is_dldecrup_disabled = true;
break;
}
...
Toggle::make('is_contraente')
->default($is_contraente)
->dehydrated()
->disabled($is_contraente_disabled),
7 replies
FFilament
Created by Marco Mapelli on 10/25/2023 in #❓┊help
Image in split table
No description
2 replies
FFilament
Created by Marco Mapelli on 9/20/2023 in #❓┊help
Logo in login page and after logged in
Hello, I’m configuring the logo, but when I’m on the login page is very small, when I’m logged in is right. How do I enlarge the logo on the login page? Can I have two different logos between the login page and after I’m logged in?
7 replies
FFilament
Created by Marco Mapelli on 9/15/2023 in #❓┊help
Customize Record Title
Hi, in ContractResource i have:
protected static ?string $recordTitleAttribute = 'id';
protected static ?string $recordTitleAttribute = 'id';
How can I customize the title so that I can see "View Contract No. [id]" or "Edit Contract No. [4]" ?
12 replies
FFilament
Created by Marco Mapelli on 7/27/2023 in #❓┊help
execute function in resource from edit
Hi, in PfcResource.php i have a static function:
public static function CalcoliQta(\Closure $get, callable $set, $livewire, $context = '')
{...
public static function CalcoliQta(\Closure $get, callable $set, $livewire, $context = '')
{...
I want to execute it when the record is in edit mode: how??
4 replies