Skip to content

Commit

Permalink
Add field editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Joao Nascimento committed Jun 23, 2024
1 parent 343ecbd commit 163c252
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"require": {
"php": "^8.1",
"filament/filament": "^3.0",
"riodwanto/filament-ace-editor": "^1.0",
"spatie/laravel-package-tools": "^1.15.0"
},
"require-dev": {
Expand Down Expand Up @@ -68,4 +69,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
12 changes: 7 additions & 5 deletions src/Livewire/ChangeEnvFileComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Filament\Forms\Contracts\HasForms;
use Filament\Notifications\Notification;
use Livewire\Component;
use Riodwanto\FilamentAceEditor\AceEditor;

class ChangeEnvFileComponent extends Component implements HasActions, HasForms
{
Expand All @@ -30,14 +31,15 @@ public function editAction()
->iconButton()
->modalHeading(__('filament-edit-env::default.heading'))
->form([
//@todo: change this to a code editor
Textarea::make('envFile')
AceEditor::make('envFile')
->label('.env')
->mode('php')
->theme('github')
->darkTheme('dracula')
->required()
->default(file_get_contents(base_path('.env')))
->autofocus()
->rows(20)
->hint(__('filament-edit-env::default.hint')),
->hint(__('filament-edit-env::default.hint'))
->height('26rem'),
])
->action(function (array $data) {
file_put_contents(base_path('.env'), $data['envFile']);
Expand Down

0 comments on commit 163c252

Please sign in to comment.