photogeodata/app/Filament/Resources/PhotoGeoData/Schemas/PhotoGeoDataForm.php
2026-05-17 09:54:41 +02:00

72 lines
2.7 KiB
PHP

<?php
namespace App\Filament\Resources\PhotoGeoData\Schemas;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
use Filament\Schemas\Schema;
use EduardoRibeiroDev\FilamentLeaflet\Fields\MapPicker;
use EduardoRibeiroDev\FilamentLeaflet\Enums\TileLayer;
class PhotoGeoDataForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
FileUpload::make('image_path')
->label('Bild')
->required()
->columnSpan('full')
->disk('public')
->directory('photos')
->image()
->helperText('Förklaring...'),
TextInput::make('title')
->label('Rubrik')
->columnSpan('full')
->required()
->helperText('Förklaring...'),
TextInput::make('uploaded_by')
->label('Uppladdat av')
->columnSpan('full')
->required()
->helperText('Förklaring...'),
DatePicker::make('captured_at')
->label('Datum då foto togs')
->columnSpan('full')
->helperText('Förklaring...'),
TextInput::make('desc')
->label('Kort beskrivning')
->columnSpan('full')
->helperText('Förklaring...'),
Textarea::make('story')
->label('Berättelse')
->columnSpanFull()
->helperText('Förklaring...'),
MapPicker::make('location')
->label('Plats')
->height(400)
->center(57.63072, 12.847787)
->zoom(15)
->autoCenter()
->tileLayersUrl(TileLayer::OpenStreetMap)
->columnSpanFull()
->latitudeFieldName('lat')
->longitudeFieldName('lng')
->helperText('Förklaring...'),
Textarea::make('metadata')
->label('Metadata (EXIF)')
->columnSpanFull()
->rows(10)
->disabled()
->dehydrated(false)
->formatStateUsing(fn ($state) => $state ? json_encode($state, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) : null)
->visible(fn ($record) => $record && filled($record->metadata)),
]);
}
}