-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from OpenSynergic/119-custom-metadata-element…
…-untuk-masing-conference add meta tag configuration
- Loading branch information
Showing
3 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
app/Panel/Livewire/Forms/Conferences/SearchEngineSetting.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace App\Panel\Livewire\Forms\Conferences; | ||
|
||
use App\Actions\Conferences\ConferenceUpdateAction; | ||
use App\Models\Conference; | ||
use Filament\Forms\Components\Actions; | ||
use Filament\Forms\Components\Actions\Action; | ||
use Filament\Forms\Components\KeyValue; | ||
use Filament\Forms\Components\Section; | ||
use Filament\Forms\Concerns\InteractsWithForms; | ||
use Filament\Forms\Contracts\HasForms; | ||
use Filament\Forms\Form; | ||
use Livewire\Component; | ||
|
||
class SearchEngineSetting extends Component implements HasForms | ||
{ | ||
use InteractsWithForms; | ||
|
||
public Conference $conference; | ||
|
||
public ?array $formData = []; | ||
|
||
public function mount(Conference $conference): void | ||
{ | ||
$this->form->fill([ | ||
...$conference->attributesToArray(), | ||
'meta' => $conference->getAllMeta(), | ||
]); | ||
} | ||
|
||
public function render() | ||
{ | ||
return view('panel.livewire.form'); | ||
} | ||
|
||
public function form(Form $form): Form | ||
{ | ||
return $form | ||
->model($this->conference) | ||
->schema([ | ||
Section::make() | ||
->schema([ | ||
KeyValue::make('meta.meta_tags') | ||
->keyLabel('Name') | ||
->valueLabel('Content') | ||
|
||
->helperText('Add meta tags, to the head of every page on your conference. Before adding any tags, consult with a technical advisor to ensure that they are compatible with your website and will not cause any problems.'), | ||
]), | ||
Actions::make([ | ||
Action::make('save') | ||
->label('Save') | ||
->successNotificationTitle('Saved!') | ||
->failureNotificationTitle('Data could not be saved.') | ||
->action(function (Action $action) { | ||
$formData = $this->form->getState(); | ||
try { | ||
ConferenceUpdateAction::run($this->conference, $formData); | ||
$action->sendSuccessNotification(); | ||
} catch (\Throwable $th) { | ||
$action->sendFailureNotification(); | ||
} | ||
}), | ||
])->alignLeft(), | ||
]) | ||
->statePath('formData'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters