albertosemesale
albertosemesale
FFilament
Created by Gush on 10/17/2023 in #❓┊help
changing betwen light mode and dark mode, how can i listen to that change and do x-show=""
I stll have trouble
6 replies
FFilament
Created by Gush on 10/17/2023 in #❓┊help
changing betwen light mode and dark mode, how can i listen to that change and do x-show=""
How did you manage this
6 replies
FFilament
Created by Gush on 10/17/2023 in #❓┊help
changing betwen light mode and dark mode, how can i listen to that change and do x-show=""
Hello
6 replies
FFilament
Created by albertosemesale on 2/28/2024 in #❓┊help
Use value of another column in the same row in a custom table
thanks
5 replies
FFilament
Created by albertosemesale on 2/28/2024 in #❓┊help
Use value of another column in the same row in a custom table
Bump
5 replies
FFilament
Created by albertosemesale on 2/19/2024 in #❓┊help
Change custom widget's input value on load in laravel filament
bump
4 replies
FFilament
Created by albertosemesale on 2/14/2024 in #❓┊help
One datepicker filter for multiple chart widgets in Admin dashboard
bump
9 replies
FFilament
Created by albertosemesale on 2/14/2024 in #❓┊help
One datepicker filter for multiple chart widgets in Admin dashboard
bunp
9 replies
FFilament
Created by albertosemesale on 2/14/2024 in #❓┊help
One datepicker filter for multiple chart widgets in Admin dashboard
bump
9 replies
FFilament
Created by albertosemesale on 2/14/2024 in #❓┊help
One datepicker filter for multiple chart widgets in Admin dashboard
Code for the chart filter
<?php

namespace App\Filament\Widgets;

use App\Models\punto;
use Flowframe\Trend\Trend;

use Flowframe\Trend\TrendValue;
use Filament\Widgets\ChartWidget;

class NewPuntoChart extends ChartWidget
{


protected static ?string $heading = 'Puntos Noroeste';

protected static ?int $sort = 2;

public $chartData;

protected $listeners = ["fromFilterChanged"];

public function fromFilterChanged($newFilter){
$this->chartData = $newFilter;
logger("Received");
logger($this->chartData);
}

protected function getFilters(): ?array
{
return [
'today' => 'Today',
'week' => 'Last week',
'month' => 'Last month',
'year' => 'This year',
];
}

protected function getData(): array
{


$trend = Trend::model(punto::class)
->dateColumn('date')->between(
start: now()->startOfYear(),
end: now()->endOfYear(),
)
->perMonth()
->count();


return [
'datasets' => [
[
'label' => 'Puntos',
'data' => $trend->map(fn(TrendValue $value) => $value->aggregate),
],
],
'labels' => $trend->map(fn(TrendValue $value) =>$value->date)
];
}

protected function getType(): string
{
return 'bar';
}
}
<?php

namespace App\Filament\Widgets;

use App\Models\punto;
use Flowframe\Trend\Trend;

use Flowframe\Trend\TrendValue;
use Filament\Widgets\ChartWidget;

class NewPuntoChart extends ChartWidget
{


protected static ?string $heading = 'Puntos Noroeste';

protected static ?int $sort = 2;

public $chartData;

protected $listeners = ["fromFilterChanged"];

public function fromFilterChanged($newFilter){
$this->chartData = $newFilter;
logger("Received");
logger($this->chartData);
}

protected function getFilters(): ?array
{
return [
'today' => 'Today',
'week' => 'Last week',
'month' => 'Last month',
'year' => 'This year',
];
}

protected function getData(): array
{


$trend = Trend::model(punto::class)
->dateColumn('date')->between(
start: now()->startOfYear(),
end: now()->endOfYear(),
)
->perMonth()
->count();


return [
'datasets' => [
[
'label' => 'Puntos',
'data' => $trend->map(fn(TrendValue $value) => $value->aggregate),
],
],
'labels' => $trend->map(fn(TrendValue $value) =>$value->date)
];
}

protected function getType(): string
{
return 'bar';
}
}
9 replies
FFilament
Created by albertosemesale on 2/14/2024 in #❓┊help
One datepicker filter for multiple chart widgets in Admin dashboard
Code for the datepicker Filter custom widget
<?php

namespace App\Filament\Widgets;

use Livewire\Livewire;
use Filament\Forms\Form;
use Filament\Widgets\Widget;
use Filament\Forms\Components\Grid;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Concerns\InteractsWithForms;

class Filters extends Widget implements HasForms
{

use InteractsWithForms;

public $selectedDate;

protected static string $view = 'filament.widgets.filters';

protected int | string | array $columnSpan = 'full';

protected static ?int $sort = 1;

public ?array $data = [];
public $dateFrom="";
public $dateTo="";

public function dateFromSelected($data){
$this->dateFrom = $data;

logger($this->dateFrom." ".$this->dateTo);

}
public function dateToSelected($data){
$this->dateTo= $data;

logger($this->dateFrom." ".$this->dateTo);

}

}
<?php

namespace App\Filament\Widgets;

use Livewire\Livewire;
use Filament\Forms\Form;
use Filament\Widgets\Widget;
use Filament\Forms\Components\Grid;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Concerns\InteractsWithForms;

class Filters extends Widget implements HasForms
{

use InteractsWithForms;

public $selectedDate;

protected static string $view = 'filament.widgets.filters';

protected int | string | array $columnSpan = 'full';

protected static ?int $sort = 1;

public ?array $data = [];
public $dateFrom="";
public $dateTo="";

public function dateFromSelected($data){
$this->dateFrom = $data;

logger($this->dateFrom." ".$this->dateTo);

}
public function dateToSelected($data){
$this->dateTo= $data;

logger($this->dateFrom." ".$this->dateTo);

}

}
9 replies