Skip to content

Commit

Permalink
Merge pull request #5 from lara-zeus/analysis-32RRdP
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
atmonshi authored Aug 19, 2022
2 parents 6807eae + 1c74e97 commit b9e14e2
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/Http/Livewire/User/FillForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,39 @@ class FillForms extends Component implements Forms\Contracts\HasForms
public Form $zeusForm;
public $zeusData = [];

protected function getFormSchema() : array
protected function getFormSchema(): array
{
$sections = [];
foreach ($this->zeusForm->sections as $section) {
$fields = [];
foreach ($section->fields as $field) {
$class = '\Filament\Forms\Components\\' . $field->type;
$setField = $class::make('zeusData.' . $field->id)
$class = '\Filament\Forms\Components\\'.$field->type;
$setField = $class::make('zeusData.'.$field->id)
->label($field->name)
->helperText($field->description)
->id($field->html_id)
->rules(collect($field->rules)->pluck('rule')->toArray());

if ($field->type === 'Select') {
$setField = $setField->options(collect(Collection::find($field->options['dataSource'])->values)->pluck('itemValue', 'itemKey')->toArray());
};
}

$fields[] = Forms\Components\Card::make()->schema([ $setField ]);
$fields[] = Forms\Components\Card::make()->schema([$setField]);
}
$sections[] = Forms\Components\Section::make($section->name)->schema($fields);
}

return $sections;
}

protected function getFormModel() : Form
protected function getFormModel(): Form
{
return $this->zeusForm;
}

public function mount($slug)
{
$this->zeusForm = Form::with([ 'sections', 'fields' ])->whereSlug($slug)->firstOrFail();
$this->zeusForm = Form::with(['sections', 'fields'])->whereSlug($slug)->firstOrFail();

foreach ($this->zeusForm->fields as $field) {
$this->zeusData[$field->id] = '';
Expand Down Expand Up @@ -91,21 +91,21 @@ public function store()
$this->validate();
$response = Response::make([
'form_id' => $this->zeusForm->id,
'user_id' => ( auth()->check() ) ? auth()->user()->id : 0,
'user_id' => (auth()->check()) ? auth()->user()->id : 0,
'status' => 'NEW',
'notes' => '',
]);
$response->save();

foreach ($this->form->getState()['zeusData'] as $field => $value) {
$fieldResponse['response'] = $value ?? '';
$fieldResponse['response'] = $value ?? '';
$fieldResponse['response_id'] = $response->id;
$fieldResponse['form_id'] = $this->zeusForm->id;
$fieldResponse['field_id'] = $field;
$fieldResponse['form_id'] = $this->zeusForm->id;
$fieldResponse['field_id'] = $field;
FieldResponse::create($fieldResponse);
}

return redirect()->route('bolt.user.submitted', [ 'slug' => $this->zeusForm->slug ]);
return redirect()->route('bolt.user.submitted', ['slug' => $this->zeusForm->slug]);
}

public function render()
Expand Down

0 comments on commit b9e14e2

Please sign in to comment.