Version 1.0.0

This commit is contained in:
2025-05-10 16:52:45 +02:00
commit bed95bff35
459 changed files with 36475 additions and 0 deletions

View File

@@ -0,0 +1,115 @@
<?php
namespace App\Filament\Pages;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Pages\Page;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\Card;
use Filament\Support\Enums\MaxWidth;
use Filament\Forms\Components\RichEditor;
class Contact extends Page implements HasForms
{
use InteractsWithForms;
public static function canAccess(): bool
{
return auth()->user()->can('manage_contact') || auth()->user()->can('admin');
}
protected static ?string $navigationIcon = 'heroicon-o-adjustments-horizontal';
protected static ?string $navigationGroup = 'Ustawienia';
protected static ?string $title = 'Kontakt';
protected static ?int $navigationSort = 3;
protected static string $view = 'filament.pages.custom-edit-page';
public function getMaxContentWidth(): MaxWidth
{
return MaxWidth::FourExtraLarge;
}
public ?array $data = [];
public function mount(): void
{
$firstRecord = \App\Models\Contact::first();
if ($firstRecord) {
$this->data = $firstRecord->toArray();
$this->form->fill($this->data);
}
}
public function form(Form $form): Form
{
return $form->schema([
Card::make()
->schema([
RichEditor::make('address')
->label('Adres')
->required()
->columnSpanFull(),
TextInput::make('telephone')
->label('Telefon')
->required()
->maxLength(2048),
TextInput::make('email')
->label('E-mail')
->required()
->maxLength(2048),
TextInput::make('fax')
->label('Faks')
->required()
->maxLength(2048),
]),
Card::make()
->schema([
TextInput::make('system_email')
->label('Na ten adres będzie wysyłany e-mail z formularza kontaktowego')
->required()
->maxLength(2048),
]),
])->statePath('data');
}
public function getFormActions(): array
{
return [
Action::make('save')
->label('Zapisz')
->action('save'),
];
}
public function save(): void
{
$validatedData = $this->form->getState();
try {
$contact = \App\Models\Contact::first();
$contact->fill($validatedData);
$contact->save();
Notification::make()
->title('Sukces!')
->body('Rekord został zapisany pomyślnie.')
->success()
->send();
} catch (\Exception $e) {
Notification::make()
->title('Błąd!')
->body('Wystąpił problem podczas zapisywania rekordu: ' . $e->getMessage())
->danger()
->send();
}
}
}

View File

@@ -0,0 +1,124 @@
<?php
namespace App\Filament\Pages;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Pages\Page;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\Card;
use Filament\Support\Enums\MaxWidth;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\FileUpload;
use Composer\InstalledVersions;
use Symfony\Component\Process\Process;
class Diagnostic extends Page
{
public static function canAccess(): bool
{
return auth()->user()->can('view_diagnostics') || auth()->user()->can('admin');
}
protected static ?string $navigationIcon = 'heroicon-o-information-circle';
protected static ?string $navigationGroup = 'Ustawienia';
protected static ?string $title = 'Diagnostyka';
protected static ?int $navigationSort = 2;
protected static string $view = 'filament.pages.diagnostic-page';
public function getMaxContentWidth(): MaxWidth
{
return MaxWidth::FourExtraLarge;
}
public array $composerPackages = [];
public array $npmPackages = [];
public function mount(): void
{
$composerJson = json_decode(file_get_contents(base_path('composer.json')), true);
$direct = [];
foreach (['require', 'require-dev'] as $section) {
if (isset($composerJson[$section])) {
foreach ($composerJson[$section] as $name => $ver) {
if (strpos($name, 'ext-') !== 0 && $name !== 'php') {
$direct[] = $name;
}
}
}
}
foreach ($direct as $package) {
if (\Composer\InstalledVersions::isInstalled($package)) {
$this->composerPackages[$package] = [
'name' => $package,
'current_version' => \Composer\InstalledVersions::getPrettyVersion($package),
'latest_version' => null,
'is_up_to_date' => true,
];
}
}
try {
$env = $_ENV;
$env['HOME'] = base_path();
$composerProcess = new Process(['composer', 'outdated', '--format=json', '--direct'], base_path(), $env);
$composerProcess->run();
if ($composerProcess->isSuccessful()) {
$outdatedComposerPackages = json_decode($composerProcess->getOutput(), true);
foreach ($outdatedComposerPackages['installed'] ?? [] as $outdatedPackage) {
if (isset($this->composerPackages[$outdatedPackage['name']])) {
$this->composerPackages[$outdatedPackage['name']]['latest_version'] = $outdatedPackage['latest'];
$this->composerPackages[$outdatedPackage['name']]['is_up_to_date'] = false;
}
}
} else {
throw new \Exception($composerProcess->getErrorOutput());
}
} catch (\Exception $e) {
dd('Composer Error: ' . $e->getMessage());
}
try {
$packageJsonPath = base_path('package.json');
if (file_exists($packageJsonPath)) {
$packageJsonContent = json_decode(file_get_contents($packageJsonPath), true);
$outdatedNpmPackages = [];
$env = $_ENV;
$env['HOME'] = base_path();
$npmProcess = new Process(['npm', 'outdated', '--json'], base_path(), $env);
$npmProcess->run();
$outdatedNpmPackages = json_decode($npmProcess->getOutput(), true);
foreach (['dependencies', 'devDependencies'] as $dependencyType) {
if (isset($packageJsonContent[$dependencyType])) {
foreach ($packageJsonContent[$dependencyType] as $name => $version) {
$this->npmPackages[] = [
'name' => $name,
'current_version' => isset($outdatedNpmPackages[$name]) ? $outdatedNpmPackages[$name]['current'] : $version,
'wanted_version' => isset($outdatedNpmPackages[$name]) ? $outdatedNpmPackages[$name]['wanted'] : null,
'latest_version' => isset($outdatedNpmPackages[$name]) ? $outdatedNpmPackages[$name]['latest'] : null,
'is_up_to_date' => !isset($outdatedNpmPackages[$name]),
];
}
}
}
}
} catch (\Exception $e) {
dd('NPM Error: ' . $e->getMessage());
}
}
}

View File

@@ -0,0 +1,156 @@
<?php
namespace App\Filament\Pages;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Pages\Page;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\Card;
use Filament\Forms\Components\Select;
use Filament\Support\Enums\MaxWidth;
class Footer extends Page implements HasForms
{
use InteractsWithForms;
public static function canAccess(): bool
{
return auth()->user()->can('manage_footer') || auth()->user()->can('admin');
}
protected static ?string $navigationIcon = 'heroicon-o-adjustments-horizontal';
protected static ?string $navigationGroup = 'Ustawienia';
protected static ?string $title = 'Stopka';
protected static ?int $navigationSort = 5;
protected static string $view = 'filament.pages.custom-edit-page';
public function getMaxContentWidth(): MaxWidth
{
return MaxWidth::FourExtraLarge;
}
public ?array $data = [];
public function mount(): void
{
$firstRecord = \App\Models\Footer::first();
if ($firstRecord) {
$this->data = $firstRecord->toArray();
$this->form->fill($this->data);
}
}
public function form(Form $form): Form
{
return $form->schema([
Card::make()
->schema([
Select::make('wosp_link')
->label('Powiązany artykuł WOŚP')
->options(function () {
return \App\Models\Article::all()->pluck('title', 'id');
})
->nullable()
->default(null)
->searchable()
->preload()
->reactive(),
]),
Card::make()
->schema([
Builder::make('links')
->label('Odnośniki')
->addActionLabel('Dodaj odnośnik')
->blocks([
Builder\Block::make('link')
->label(function (?array $state): string {
if ($state === null) {
return 'Odnośnik';
}
return $state['name'] ?? 'Odnośnik';
})
->schema([
TextInput::make('name')
->label('Nazwa')
->required(),
TextInput::make('url')
->label('Ścieżka lub URL')
->required(),
Toggle::make('external')
->label('Otwieraj w nowej karcie')
->required(),
])
->columns(2),
])
]),
Card::make()
->schema([
Builder::make('registration_hours')
->label('Godziny rejestracji')
->addActionLabel('Dodaj dzień z godzinami')
->blocks([
Builder\Block::make('registration_hour')
->label(function (?array $state): string {
if ($state === null) {
return 'Godziny rejestracji';
}
return $state['day'] ?? 'Godzina rejestracji';
})
->schema([
TextInput::make('day')
->label('Dzień tygodnia')
->required(),
TextInput::make('hours')
->label('Godziny')
->required(),
])
->columns(2),
])
])
])->statePath('data');
}
public function getFormActions(): array
{
return [
Action::make('save')
->label('Zapisz')
->action('save'),
];
}
public function save(): void
{
$validatedData = $this->form->getState();
try {
$footer = \App\Models\Footer::first();
$footer->fill($validatedData);
$footer->save();
Notification::make()
->title('Sukces!')
->body('Rekord został zapisany pomyślnie.')
->success()
->send();
} catch (\Exception $e) {
Notification::make()
->title('Błąd!')
->body('Wystąpił problem podczas zapisywania rekordu: ' . $e->getMessage())
->danger()
->send();
}
}
}

View File

@@ -0,0 +1,157 @@
<?php
namespace App\Filament\Pages;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Pages\Page;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\Card;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\FileUpload;
use Filament\Support\Enums\MaxWidth;
class Header extends Page implements HasForms
{
use InteractsWithForms;
public static function canAccess(): bool
{
return auth()->user()->can('manage_header') || auth()->user()->can('admin');
}
protected static ?string $navigationIcon = 'heroicon-o-adjustments-horizontal';
protected static ?string $navigationGroup = 'Ustawienia';
protected static ?string $title = 'Nagłówek';
protected static ?int $navigationSort = 4;
protected static string $view = 'filament.pages.custom-edit-page';
public function getMaxContentWidth(): MaxWidth
{
return MaxWidth::FourExtraLarge;
}
public ?array $data = [];
public function mount(): void
{
$firstRecord = \App\Models\Header::first();
if ($firstRecord) {
$this->data = $firstRecord->toArray();
$this->form->fill($this->data);
}
}
public function form(Form $form): Form
{
return $form->schema([
Card::make()
->schema([
Grid::make(2)
->schema([
TextInput::make('title1')
->label('Tytuł 1')
->required()
->maxLength(2048),
TextInput::make('title2')
->label('Tytuł 2')
->required()
->maxLength(2048),
]),
TextInput::make('subtitle')
->label('Podtytuł')
->maxLength(2048),
FileUpload::make('logo')
->image()
->imageEditor()
->acceptedFileTypes(['image/png'])
->label('Logo strony')
->disk('public')
->directory('header-logo')
->default(null),
TextInput::make('telephone')
->label('Numer telefonu')
->required()
->maxLength(15),
]),
Card::make()
->schema([
Builder::make('links')
->label('Odnośniki')
->addActionLabel('Dodaj odnośnik')
->blocks([
Builder\Block::make('link')
->label(function (?array $state): string {
if ($state === null) {
return 'Odnośnik';
}
return $state['name'] ?? 'Odnośnik';
})
->schema([
TextInput::make('name')
->label('Nazwa')
->required(),
FileUpload::make('icon')
->image()
->imageEditor()
->label('Ikona')
->disk('public')
->directory('header-links')
->default(null),
TextInput::make('icon-alt')
->label('Opis ikony')
->default(null),
TextInput::make('url')
->label('Ścieżka lub URL')
->required(),
Toggle::make('external')
->label('Otwieraj w nowej karcie')
->required(),
])
->columns(1),
])
])
])->statePath('data');
}
public function getFormActions(): array
{
return [
Action::make('save')
->label('Zapisz')
->action('save'),
];
}
public function save(): void
{
$validatedData = $this->form->getState();
try {
$header = \App\Models\Header::first();
$header->fill($validatedData);
$header->save();
Notification::make()
->title('Sukces!')
->body('Rekord został zapisany pomyślnie.')
->success()
->send();
} catch (\Exception $e) {
Notification::make()
->title('Błąd!')
->body('Wystąpił problem podczas zapisywania rekordu: ' . $e->getMessage())
->danger()
->send();
}
}
}

View File

@@ -0,0 +1,151 @@
<?php
namespace App\Filament\Pages;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Pages\Page;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\Card;
use Filament\Support\Enums\MaxWidth;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\FileUpload;
class Homepage extends Page implements HasForms
{
use InteractsWithForms;
public static function canAccess(): bool
{
return auth()->user()->can('manage_homepage') || auth()->user()->can('admin');
}
protected static ?string $navigationIcon = 'heroicon-o-home';
protected static ?string $navigationGroup = 'Treści';
protected static ?string $title = 'Strona główna';
protected static ?int $navigationSort = 3;
protected static string $view = 'filament.pages.custom-edit-page';
public function getMaxContentWidth(): MaxWidth
{
return MaxWidth::FourExtraLarge;
}
public ?array $data = [];
public function mount(): void
{
$firstRecord = \App\Models\Homepage::first();
if ($firstRecord) {
$this->data = $firstRecord->toArray();
$this->form->fill($this->data);
}
}
public function form(Form $form): Form
{
return $form->schema([
Card::make()
->schema([
TextInput::make('title')
->label('Tytuł strony')
->required()
->maxLength(2048),
FileUpload::make('photo')
->image()
->imageEditor()
->disk('public')
->directory('homepage')
->label('Zdjęcie'),
RichEditor::make('content')
->label('Treść strony')
->required()
->columnSpanFull(),
]),
Card::make()
->schema([
Builder::make('carousel_photos')
->label('Zdjęcia w karuzeli')
->addActionLabel('Dodaj zdjęcie')
->collapsible()
->collapsed()
->reorderable()
->blocks([
Builder\Block::make('carousel_photo')
->label(function (?array $state): string {
if ($state === null) {
return 'Zdjęcie';
}
return $state['name'] ?? 'Zdjęcie';
})
->schema([
TextInput::make('name')
->label('Nazwa')
->required(),
FileUpload::make('photo')
->image()
->imageEditor()
->required()
->label('Zdjęcie')
->disk('public')
->directory('homepage-carousel')
->default(null),
TextInput::make('description')
->label('Opis')
->default(null)
->required(),
TextInput::make('url')
->label('Ścieżka lub URL')
->required(),
Toggle::make('external')
->label('Otwieraj w nowej karcie')
->default(false)
->required(),
])
->columns(1),
])
])
])->statePath('data');
}
public function getFormActions(): array
{
return [
Action::make('save')
->label('Zapisz')
->action('save'),
];
}
public function save(): void
{
$validatedData = $this->form->getState();
try {
$homepage = \App\Models\Homepage::first();
$homepage->fill($validatedData);
$homepage->save();
Notification::make()
->title('Sukces!')
->body('Rekord został zapisany pomyślnie.')
->success()
->send();
} catch (\Exception $e) {
Notification::make()
->title('Błąd!')
->body('Wystąpił problem podczas zapisywania rekordu: ' . $e->getMessage())
->danger()
->send();
}
}
}

View File

@@ -0,0 +1,103 @@
<?php
namespace App\Filament\Pages;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Pages\Page;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\Card;
use Filament\Support\Enums\MaxWidth;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Select;
class Location extends Page implements HasForms
{
use InteractsWithForms;
public static function canAccess(): bool
{
return auth()->user()->can('manage_location') || auth()->user()->can('admin');
}
protected static ?string $navigationIcon = 'heroicon-o-map-pin';
protected static ?string $navigationGroup = 'Pozostałe';
protected static ?string $title = 'Mapa budynków';
protected static ?int $navigationSort = 2;
protected static string $view = 'filament.pages.custom-edit-page';
public function getMaxContentWidth(): MaxWidth
{
return MaxWidth::FourExtraLarge;
}
public ?array $data = [];
public function mount(): void
{
$firstRecord = \App\Models\Location::first();
if ($firstRecord) {
$this->data = $firstRecord->toArray();
$this->form->fill($this->data);
}
}
public function form(Form $form): Form
{
return $form->schema([
Card::make()
->schema([
Select::make('photo_id')
->label('Powiązane zdjęcie')
->options(function () {
return \App\Models\Photo::all()->pluck('image_name', 'id');
})
->nullable()
->default(null)
->searchable()
->preload()
->reactive(),
]),
])->statePath('data');
}
public function getFormActions(): array
{
return [
Action::make('save')
->label('Zapisz')
->action('save'),
];
}
public function save(): void
{
$validatedData = $this->form->getState();
try {
$location = \App\Models\Location::first();
$location->fill($validatedData);
$location->save();
Notification::make()
->title('Sukces!')
->body('Rekord został zapisany pomyślnie.')
->success()
->send();
} catch (\Exception $e) {
Notification::make()
->title('Błąd!')
->body('Wystąpił problem podczas zapisywania rekordu: ' . $e->getMessage())
->danger()
->send();
}
}
}

View File

@@ -0,0 +1,103 @@
<?php
namespace App\Filament\Pages;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Pages\Page;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\Card;
use Filament\Support\Enums\MaxWidth;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Select;
class Price extends Page implements HasForms
{
use InteractsWithForms;
public static function canAccess(): bool
{
return auth()->user()->can('manage_prices') || auth()->user()->can('admin');
}
protected static ?string $navigationIcon = 'heroicon-o-banknotes';
protected static ?string $navigationGroup = 'Pozostałe';
protected static ?string $title = 'Cennik badań';
protected static ?int $navigationSort = 1;
protected static string $view = 'filament.pages.custom-edit-page';
public function getMaxContentWidth(): MaxWidth
{
return MaxWidth::FourExtraLarge;
}
public ?array $data = [];
public function mount(): void
{
$firstRecord = \App\Models\Price::first();
if ($firstRecord) {
$this->data = $firstRecord->toArray();
$this->form->fill($this->data);
}
}
public function form(Form $form): Form
{
return $form->schema([
Card::make()
->schema([
Select::make('attachment_id')
->label('Powiązany załącznik')
->options(function () {
return \App\Models\Attachment::all()->pluck('file_name', 'id');
})
->nullable()
->default(null)
->searchable()
->preload()
->reactive(),
]),
])->statePath('data');
}
public function getFormActions(): array
{
return [
Action::make('save')
->label('Zapisz')
->action('save'),
];
}
public function save(): void
{
$validatedData = $this->form->getState();
try {
$price = \App\Models\Price::first();
$price->fill($validatedData);
$price->save();
Notification::make()
->title('Sukces!')
->body('Rekord został zapisany pomyślnie.')
->success()
->send();
} catch (\Exception $e) {
Notification::make()
->title('Błąd!')
->body('Wystąpił problem podczas zapisywania rekordu: ' . $e->getMessage())
->danger()
->send();
}
}
}