Anthaas
Anthaas
FFilament
Created by Anthaas on 1/24/2024 in #❓┊help
Nullable dates in spatie/laravel-settings
Thanks again.
17 replies
FFilament
Created by Anthaas on 1/24/2024 in #❓┊help
Nullable dates in spatie/laravel-settings
Yeah - I think I'll go with the dehydrate method, that way I am only concerned with ever casting it between the two types when serialising/deserialising to and from the repository.
17 replies
FFilament
Created by Anthaas on 1/24/2024 in #❓┊help
Nullable dates in spatie/laravel-settings
Ahhh, so the prop needs to be a string for that. Again - slightly at odds with the underlying package, but I get why. Wondering what the best approach is. Tempted to suggest the dehydrate method, because at least when you access the settings class at some other point the property is correctly typed.
17 replies
FFilament
Created by Anthaas on 1/24/2024 in #❓┊help
Nullable dates in spatie/laravel-settings
Interesting. That's done it. I completely understand why that is the case - wonder if this could somehow be abstracted away with some sort of sensible default behaviour for the users. The underlying library suggests that this isn't necessary, so I guess its the filament package that needs this handling. Cheers!
17 replies
FFilament
Created by Anthaas on 1/24/2024 in #❓┊help
Nullable dates in spatie/laravel-settings
The up function of the migration:
public function up(): void
{
$this->migrator->add('announcement.content', '');
$this->migrator->add('announcement.showFrom');
$this->migrator->add('announcement.showUntil');
}
public function up(): void
{
$this->migrator->add('announcement.content', '');
$this->migrator->add('announcement.showFrom');
$this->migrator->add('announcement.showUntil');
}
17 replies
FFilament
Created by Anthaas on 1/24/2024 in #❓┊help
Nullable dates in spatie/laravel-settings
Hang on - I can easily just share the two classes involved here without needing to obfuscate. AnnouncementSettings:
<?php

namespace App\Settings;

use Carbon\Carbon;
use Spatie\LaravelSettings\Settings;

class AnnouncementSettings extends Settings
{
public string $content;
public ?Carbon $showFrom;
public ?Carbon $showUntil;

public static function group(): string
{
return 'announcement';
}
}
<?php

namespace App\Settings;

use Carbon\Carbon;
use Spatie\LaravelSettings\Settings;

class AnnouncementSettings extends Settings
{
public string $content;
public ?Carbon $showFrom;
public ?Carbon $showUntil;

public static function group(): string
{
return 'announcement';
}
}
ManageAnnouncement:
<?php

namespace App\Filament\Pages;

use App\Settings\AnnouncementSettings;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\SettingsPage;

class ManageAnnouncement extends SettingsPage
{
protected static ?string $navigationIcon = 'heroicon-o-megaphone';
protected static ?string $navigationLabel = 'Announcement';
protected static ?string $navigationGroup = 'CONTENT';

protected ?string $heading = 'Announcement';

protected static string $settings = AnnouncementSettings::class;

public function form(Form $form): Form
{
return $form
->columns(1)
->schema([
TextInput::make('content')
->label('Content')
->maxLength(120),
DateTimePicker::make('showFrom')
->label('Show From')
->prefixIcon('heroicon-o-calendar')
->seconds(false)
->native(false)
->format('Y-m-d H:i:s'),
DateTimePicker::make('showUntil')
->label('Show Until')
->prefixIcon('heroicon-o-calendar')
->seconds(false)
->native(false)
->format('Y-m-d H:i:s'),
]);
}
}
<?php

namespace App\Filament\Pages;

use App\Settings\AnnouncementSettings;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\SettingsPage;

class ManageAnnouncement extends SettingsPage
{
protected static ?string $navigationIcon = 'heroicon-o-megaphone';
protected static ?string $navigationLabel = 'Announcement';
protected static ?string $navigationGroup = 'CONTENT';

protected ?string $heading = 'Announcement';

protected static string $settings = AnnouncementSettings::class;

public function form(Form $form): Form
{
return $form
->columns(1)
->schema([
TextInput::make('content')
->label('Content')
->maxLength(120),
DateTimePicker::make('showFrom')
->label('Show From')
->prefixIcon('heroicon-o-calendar')
->seconds(false)
->native(false)
->format('Y-m-d H:i:s'),
DateTimePicker::make('showUntil')
->label('Show Until')
->prefixIcon('heroicon-o-calendar')
->seconds(false)
->native(false)
->format('Y-m-d H:i:s'),
]);
}
}
17 replies
FFilament
Created by Anthaas on 1/24/2024 in #❓┊help
Nullable dates in spatie/laravel-settings
@awcodes Sorry for the delay. The duplicate property name was poor copy/paste on my part to show a minimal example. I have modified the fill function in laravel-settings/src/Settings to catch the TypeError as follows:
foreach ($properties as $name => $payload) {
try {
$this->{$name} = $payload;
} catch (\TypeError $e) {
dd($name, $payload);
}
}
foreach ($properties as $name => $payload) {
try {
$this->{$name} = $payload;
} catch (\TypeError $e) {
dd($name, $payload);
}
}
The value I get out is when selecting the 24th Jan 2024 at midnight is 2024-01-24 00:00. Appending the seconds(false) call with ->format('Y-m-d H:i:s') results in a full Y-m-d H:i:s format: 2024-01-24 00:00:00. I continue to get the same TypeError thrown.
17 replies
FFilament
Created by Anthaas on 1/24/2024 in #❓┊help
Nullable dates in spatie/laravel-settings
@ConnorHowell I’ve tried both of those. Getting the same error.
17 replies
FFilament
Created by Anthaas on 1/24/2024 in #❓┊help
Nullable dates in spatie/laravel-settings
It seems that casts just aren't running/working? With the global casters, it shouldn't try to assign a string to that property, should it?
17 replies
FFilament
Created by Anthaas on 1/22/2024 in #❓┊help
What is the best way to have Filament manage a single text entry?
Hmm maybe something like Spatie’s settings package could work.
2 replies
FFilament
Created by Anthaas on 10/6/2023 in #❓┊help
Customising HTML tags used by Rich Editor
Cheers. Was the answer I needed.
6 replies
FFilament
Created by Anthaas on 10/6/2023 in #❓┊help
Customising HTML tags used by Rich Editor
Hmm, or is it that I just need to set CSS for classless HTML tags? Seems a bit....broad?
6 replies
FFilament
Created by Anthaas on 10/4/2023 in #❓┊help
Modifying default page layout.
Of course 🙂 Was just letting you know so you didn't have it littering your GitHub, and beyond that, just showing appreciation 😄
59 replies
FFilament
Created by Anthaas on 10/4/2023 in #❓┊help
Modifying default page layout.
I've revoked your access to that repository now - thanks again. Appreciate it.
59 replies
FFilament
Created by Anthaas on 10/4/2023 in #❓┊help
Modifying default page layout.
Yeah - that seems to have sorted it. Thank you for helping. The odds of that 😂 just my luck.
59 replies
FFilament
Created by Anthaas on 10/4/2023 in #❓┊help
Modifying default page layout.
Good evening, I'll be around for a while now.
59 replies
FFilament
Created by Anthaas on 10/4/2023 in #❓┊help
Modifying default page layout.
Not a problem at all, I'm thankful for your offer to help. I will be heading off for the night soon anyway. I'll catch you tomorrow, if that is OK?
59 replies
FFilament
Created by Anthaas on 10/4/2023 in #❓┊help
Modifying default page layout.
I am about now, so whenever is good for you.
59 replies
FFilament
Created by Anthaas on 10/4/2023 in #❓┊help
Modifying default page layout.
No worries - you are helping me, so I am flexible to you.
59 replies
FFilament
Created by Anthaas on 10/4/2023 in #❓┊help
Modifying default page layout.
I have invited you to the repository now. The branch is add.filament . Thank you for your help on this. I am also working tomorrow, so won't be on until perhaps about 5:30PM UK time.
59 replies