HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //home/posscale/.trash/1app.2/Filament/Pages/Settings.php
<?php

namespace App\Filament\Pages;

use App\Models\GeneralSettings;
use Filament\Actions\Action;
use Filament\Actions\Concerns\CanUseDatabaseTransactions;
use Filament\Actions\Contracts\HasActions;
use Filament\Facades\Filament;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Pages\Page;
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
use Illuminate\Database\Eloquent\Model;
use Filament\Forms\Components\Section;
use Filament\Forms\Concerns\HasState;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Pages\Concerns\HasUnsavedDataChangesAlert;
use Filament\Pages\Concerns\InteractsWithFormActions;
use Filament\Resources\Pages\EditRecord;
use Filament\Resources\Pages\ViewRecord;
use Filament\Support\Exceptions\Halt;
use Filament\Resources\Forms\Components;

/**
 * @property Form $form
 */
class Settings extends Page
{

    use InteractsWithForms;
    use InteractsWithFormActions;
    use HasUnsavedDataChangesAlert;
   
    protected $rules = [
        'notification_status' => 'required'
    ];
    protected static ?string $navigationIcon = 'heroicon-o-document-text';

    protected static string $view = 'filament.pages.settings';

    protected static ?string $title = 'General Settings';

    protected static ?string $navigationLabel = 'General Settings';

    public function mount($id = 1): void
    {
        $all_settings = GeneralSettings::all();
        var_dump($all_settings);
        $fill_data = [];
        foreach ($all_settings as $setting) {
            $fill_data[$setting->key] = $setting->value;
        }

    }


  

    protected function getFormSchema(): array
    {
        return [
            Section::make('General settings')
                ->description('This settings will apply for main site only')
                ->columns(3)
                ->schema([
                    Select::make('notification_status')->options([
                        '1' => 'Active',
                        '0' => 'Disable',
                    ]),
                    TextInput::make('notification_email')->type('email'),
                    TextInput::make('toner_level')->type('number'),
                ])
        ];
    }

    public function getFormActions(): array
    {
        return array_merge([
            Action::make('Save Settings')->action('save'),
        ]);
    }

    public function save(): void
    {
        try {
            $data = $this->form->getState();
            print_r($data);
            exit;
            foreach ($data as $key => $value) {
                GeneralSettings::where('key', $key)->update(['value' => $value]);
            }
        } catch (Halt $exception) {
            return;
        }

        Notification::make()
            ->success()->title('Settings Stored Successfully')->send();
    }
}