Skip to content

Commit

Permalink
Added Limit option
Browse files Browse the repository at this point in the history
  • Loading branch information
Poseidon281 committed Jun 11, 2024
1 parent 45cd368 commit 5cdef59
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 13 deletions.
8 changes: 8 additions & 0 deletions app/Filament/Resources/SettingResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Filament\Tables\Table;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Select;
use Schmeits\FilamentCharacterCounter\Forms\Components\TextInput as LimitInput;

class SettingResource extends Resource
{
Expand Down Expand Up @@ -59,6 +60,13 @@ public static function table(Table $table): Table
->placeholder($record->description)
->type('number'),
],
'limit' => [
LimitInput::make('value')
->label($record->label)
->maxLength($record->limit)
->showInsideControl(false)
->placeholder($record->description),
],
default => [
TextInput::make('value')
->label($record->label)
Expand Down
14 changes: 5 additions & 9 deletions app/Models/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ class Setting extends Model

public $incrementing = false;

protected $fillable = ['key', 'label', 'value', 'type', 'attributes', 'description'];
protected $fillable = ['key', 'label', 'value', 'type', 'attributes', 'description', 'limit'];

protected $casts = ['attributes' => 'array'];

public static function getValue($key)
{
$setting = static::where('key', $key)->first();

return $setting ? $setting->value : null;
}
protected $casts = [
'attributes' => 'array',
'limit' => 'integer',
];
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"prologue/alerts": "^1.2",
"ryangjchandler/blade-tabler-icons": "^2.3",
"s1lentium/iptools": "~1.2.0",
"schmeits/filament-character-counter": "^1.2",
"spatie/laravel-fractal": "^6.2",
"spatie/laravel-query-builder": "^5.8.1",
"spatie/temporary-directory": "^2.2",
Expand Down
86 changes: 84 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions database/migrations/2024_05_19_154057_recreate_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ public function up(): void
$table->text('value')->nullable();
$table->json('attributes')->nullable();
$table->string('type');
$table->longText('description');
$table->longText('description')->nullable();
$table->integer('limit')->nullable();
$table->timestamps();
});

Setting::create([
'key' => 'APP_NAME',
'label' => 'Panel Name',
'value' => 'Pelican',
'type' => 'text',
'type' => 'limit',
'limit' => 18,
'description' => 'This is the name that is used throughout the panel and in emails sent to clients.',
]);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
'character_seperator' => ' / ',
'character_label' => 'characters',
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
'character_seperator' => ' / ',
'character_label' => 'karakters',
];

0 comments on commit 5cdef59

Please sign in to comment.