F
Filament8mo ago
Baspa

The `columnSpan` property is overridden in each render

On the first render it appears as a full columnspan. But on a second render it reverts back to 1/2 as it seems. Any idea what might causing this? I guess it has something to do with the render method?
<?php

namespace App\Filament\Widgets;

use Filament\Widgets\Widget;
use Illuminate\Support\Carbon;
use App\Domain\Widget\Actions\GetWeather;
use App\Domain\Widget\Actions\GetForecast;
use Illuminate\Contracts\View\View;

class WeatherWidget extends Widget
{
public array $report;
public ?string $forecast = null;
public string $time;

public string $width;
public int $order;

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

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

public function render(): View
{
$this->report = GetWeather::run();
$this->forecast = GetForecast::run(
lat: 51.4946, // Bergen op Zoom
long: 4.2872
);

$this->time = $this->forecast ? Carbon::parse($this->forecast)->format('H:i') : '';

return view(static::$view, [
'report' => $this->report,
'forecast' => $this->forecast,
'time' => $this->time,
]);
}
}
<?php

namespace App\Filament\Widgets;

use Filament\Widgets\Widget;
use Illuminate\Support\Carbon;
use App\Domain\Widget\Actions\GetWeather;
use App\Domain\Widget\Actions\GetForecast;
use Illuminate\Contracts\View\View;

class WeatherWidget extends Widget
{
public array $report;
public ?string $forecast = null;
public string $time;

public string $width;
public int $order;

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

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

public function render(): View
{
$this->report = GetWeather::run();
$this->forecast = GetForecast::run(
lat: 51.4946, // Bergen op Zoom
long: 4.2872
);

$this->time = $this->forecast ? Carbon::parse($this->forecast)->format('H:i') : '';

return view(static::$view, [
'report' => $this->report,
'forecast' => $this->forecast,
'time' => $this->time,
]);
}
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server