From b9205ec4bf5735e350dd67e28aa6dc35cd079cac Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Sun, 11 Sep 2022 13:21:45 +0000 Subject: [PATCH] Apply fixes from StyleCI --- database/seeders/BoltSeeder.php | 40 +++++++++---------- src/Events/FormMounted.php | 4 -- src/Fields/Classes/Checkbox.php | 2 +- src/Fields/Classes/CheckboxList.php | 2 +- src/Fields/Classes/FileUpload.php | 5 +-- src/Fields/Classes/MultiSelect.php | 2 +- src/Fields/Classes/Radio.php | 2 +- src/Fields/Classes/Select.php | 4 +- src/Fields/Classes/TextInput.php | 6 +-- src/Filament/Resources/FormResource.php | 28 ++++++------- .../FormResource/Pages/CreateForm.php | 2 +- .../Resources/FormResource/Pages/EditForm.php | 6 +-- .../Resources/FormResource/Schemata.php | 6 +-- src/Filament/Resources/ResponseResource.php | 6 +-- .../Pages/BrowseResponses.php | 2 +- .../ResponseResource/Pages/ListResponses.php | 4 +- src/Http/Livewire/FillForms.php | 28 ++++++------- src/Models/FieldResponse.php | 2 +- 18 files changed, 73 insertions(+), 78 deletions(-) diff --git a/database/seeders/BoltSeeder.php b/database/seeders/BoltSeeder.php index d24136a7..48012c48 100644 --- a/database/seeders/BoltSeeder.php +++ b/database/seeders/BoltSeeder.php @@ -41,7 +41,7 @@ public function run() 'itemIsDefault' => false, ], ], JSON_THROW_ON_ERROR), - 'created_at' => now() + 'created_at' => now(), ]); $collection_2 = DB::table('collections')->insertGetId([ 'name' => 'yes no maybe list', @@ -62,14 +62,14 @@ public function run() 'itemIsDefault' => false, ], ], JSON_THROW_ON_ERROR), - 'created_at' => now() + 'created_at' => now(), ]); $category = DB::table('categories')->insertGetId([ 'name' => json_encode(['en' => 'General Forms', 'ar' => 'النماذج العامة'], JSON_THROW_ON_ERROR), 'desc' => json_encode(['en' => 'all other Forms', 'ar' => 'كافة النماذج'], JSON_THROW_ON_ERROR), 'slug' => 'general-forms', - 'created_at' => now() + 'created_at' => now(), ]); $form = DB::table('forms')->insertGetId([ @@ -91,18 +91,18 @@ public function run() 'is_active' => 1, 'desc' => json_encode(['en' => 'send us your Feedback about our service', 'ar' => 'شاركنا تقييمك على خدماتنا'], JSON_THROW_ON_ERROR), 'details' => json_encode(['en' => 'please use the same email address you used on registration, so we can add points to your account', 'ar' => 'الرجاء استخدام نفس البريد الإلكتروني المستخدم في التسجيل لاضافة النقاط لحسابك'], JSON_THROW_ON_ERROR), - 'created_at' => now() + 'created_at' => now(), ]); $section1 = DB::table('sections')->insertGetId([ 'name' => json_encode(['en' => 'your info', 'ar' => 'بياناتك الشخصية'], JSON_THROW_ON_ERROR), 'form_id' => $form, - 'created_at' => now() + 'created_at' => now(), ]); $section2 = DB::table('sections')->insertGetId([ 'name' => json_encode(['en' => 'feedback', 'ar' => 'التقييم'], JSON_THROW_ON_ERROR), 'form_id' => $form, - 'created_at' => now() + 'created_at' => now(), ]); $section1_field_1 = DB::table('fields')->insertGetId([ @@ -114,7 +114,7 @@ public function run() 'is_required' => true, ], JSON_THROW_ON_ERROR), 'type' => '\LaraZeus\Bolt\Fields\Classes\TextInput', - 'created_at' => now() + 'created_at' => now(), ]); $section1_field_2 = DB::table('fields')->insertGetId([ 'name' => json_encode(['en' => 'your Email', 'ar' => 'البريد الإلكتروني'], JSON_THROW_ON_ERROR), @@ -125,7 +125,7 @@ public function run() 'is_required' => true, ], JSON_THROW_ON_ERROR), 'type' => '\LaraZeus\Bolt\Fields\Classes\TextInput', - 'created_at' => now() + 'created_at' => now(), ]); $section2_field_1 = DB::table('fields')->insertGetId([ 'name' => json_encode(['en' => 'rate your experience', 'ar' => 'تقييم تجربتك معنا'], JSON_THROW_ON_ERROR), @@ -137,7 +137,7 @@ public function run() 'is_inline' => true, ], JSON_THROW_ON_ERROR), 'type' => '\LaraZeus\Bolt\Fields\Classes\Radio', - 'created_at' => now() + 'created_at' => now(), ]); $section2_field_2 = DB::table('fields')->insertGetId([ 'name' => json_encode(['en' => 'would you recommend our services to others', 'ar' => 'هل تنصح الآخرين باستخدام خدماتنا'], JSON_THROW_ON_ERROR), @@ -148,7 +148,7 @@ public function run() 'is_required' => true, ], JSON_THROW_ON_ERROR), 'type' => '\LaraZeus\Bolt\Fields\Classes\Select', - 'created_at' => now() + 'created_at' => now(), ]); $response_1 = DB::table('responses')->insertGetId([ @@ -156,7 +156,7 @@ public function run() 'user_id' => null, 'status' => 'NEW', 'notes' => null, - 'created_at' => now() + 'created_at' => now(), ]); $response_1_field_1 = DB::table('field_responses')->insertGetId([ @@ -164,28 +164,28 @@ public function run() 'field_id' => $section1_field_1, 'response_id' => $response_1, 'response' => 'My First Name', - 'created_at' => now() + 'created_at' => now(), ]); $response_1_field_2 = DB::table('field_responses')->insertGetId([ 'form_id' => $form, 'field_id' => $section1_field_2, 'response_id' => $response_1, 'response' => 'its@not.important', - 'created_at' => now() + 'created_at' => now(), ]); $response_1_field_3 = DB::table('field_responses')->insertGetId([ 'form_id' => $form, 'field_id' => $section2_field_1, 'response_id' => $response_1, 'response' => '2', - 'created_at' => now() + 'created_at' => now(), ]); $response_1_field_4 = DB::table('field_responses')->insertGetId([ 'form_id' => $form, 'field_id' => $section2_field_2, 'response_id' => $response_1, 'response' => 'Maybe', - 'created_at' => now() + 'created_at' => now(), ]); $response_2 = DB::table('responses')->insertGetId([ @@ -193,7 +193,7 @@ public function run() 'user_id' => 2, 'status' => 'NEW', 'notes' => null, - 'created_at' => now() + 'created_at' => now(), ]); $response_2_field_1 = DB::table('field_responses')->insertGetId([ @@ -201,28 +201,28 @@ public function run() 'field_id' => $section1_field_1, 'response_id' => $response_2, 'response' => 'My First Name', - 'created_at' => now() + 'created_at' => now(), ]); $response_2_field_2 = DB::table('field_responses')->insertGetId([ 'form_id' => $form, 'field_id' => $section1_field_2, 'response_id' => $response_2, 'response' => 'its@not.important', - 'created_at' => now() + 'created_at' => now(), ]); $response_2_field_3 = DB::table('field_responses')->insertGetId([ 'form_id' => $form, 'field_id' => $section2_field_1, 'response_id' => $response_2, 'response' => '2', - 'created_at' => now() + 'created_at' => now(), ]); $response_2_field_4 = DB::table('field_responses')->insertGetId([ 'form_id' => $form, 'field_id' => $section2_field_2, 'response_id' => $response_2, 'response' => 'maybe', - 'created_at' => now() + 'created_at' => now(), ]); } } diff --git a/src/Events/FormMounted.php b/src/Events/FormMounted.php index 36386181..722bb7da 100644 --- a/src/Events/FormMounted.php +++ b/src/Events/FormMounted.php @@ -2,14 +2,10 @@ namespace LaraZeus\Bolt\Events; -use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Broadcasting\PrivateChannel; -use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; -use LaraZeus\Bolt\Models\Form; class FormMounted { diff --git a/src/Fields/Classes/Checkbox.php b/src/Fields/Classes/Checkbox.php index 65b69cb2..519b5f55 100644 --- a/src/Fields/Classes/Checkbox.php +++ b/src/Fields/Classes/Checkbox.php @@ -28,7 +28,7 @@ public static function getOptions() public function getResponse($field, $resp): string { - if (!empty($resp->response)) { + if (! empty($resp->response)) { $col = Collection::find($field->options['dataSource']); return collect($col->values)->where('itemKey', $resp->response)->first()['itemValue']; diff --git a/src/Fields/Classes/CheckboxList.php b/src/Fields/Classes/CheckboxList.php index d81732d6..031bd5a0 100644 --- a/src/Fields/Classes/CheckboxList.php +++ b/src/Fields/Classes/CheckboxList.php @@ -29,7 +29,7 @@ public static function getOptions() public function getResponse($field, $resp): string { - if (!empty($resp->response)) { + if (! empty($resp->response)) { $col = Collection::find($field->options['dataSource']); return collect($col->values)->where('itemKey', $resp->response)->first()['itemValue']; diff --git a/src/Fields/Classes/FileUpload.php b/src/Fields/Classes/FileUpload.php index f7548b88..e6b02555 100644 --- a/src/Fields/Classes/FileUpload.php +++ b/src/Fields/Classes/FileUpload.php @@ -3,7 +3,6 @@ namespace LaraZeus\Bolt\Fields\Classes; use Filament\Forms\Components\Toggle; -use Illuminate\Support\Facades\Storage; use LaraZeus\Bolt\Fields\FieldsContract; class FileUpload extends FieldsContract @@ -28,8 +27,8 @@ public static function getOptions() public function getResponse($field, $resp): string { return view('zeus-bolt::fields.file-upload') - ->with('resp',$resp) - ->with('field',$field) + ->with('resp', $resp) + ->with('field', $field) ->render(); } } diff --git a/src/Fields/Classes/MultiSelect.php b/src/Fields/Classes/MultiSelect.php index fdc09f12..95862360 100644 --- a/src/Fields/Classes/MultiSelect.php +++ b/src/Fields/Classes/MultiSelect.php @@ -28,7 +28,7 @@ public static function getOptions() public function getResponse($field, $resp): string { - if (!empty($resp->response)) { + if (! empty($resp->response)) { $col = Collection::find($field->options['dataSource']); return collect($col->values)->where('itemKey', $resp->response)->first()['itemValue']; diff --git a/src/Fields/Classes/Radio.php b/src/Fields/Classes/Radio.php index e44c84b8..0a0154d2 100644 --- a/src/Fields/Classes/Radio.php +++ b/src/Fields/Classes/Radio.php @@ -29,7 +29,7 @@ public static function getOptions() public function getResponse($field, $resp): string { - if (!empty($resp->response)) { + if (! empty($resp->response)) { $col = Collection::find($field->options['dataSource']); return collect($col->values)->where('itemKey', $resp->response)->first()['itemValue']; diff --git a/src/Fields/Classes/Select.php b/src/Fields/Classes/Select.php index 7d61df84..6ba23997 100644 --- a/src/Fields/Classes/Select.php +++ b/src/Fields/Classes/Select.php @@ -25,7 +25,7 @@ public static function getOptions() ]; } - public function getResponse($field, $resp) : string + public function getResponse($field, $resp): string { if (empty($resp->response)) { return ''; @@ -42,7 +42,7 @@ public function getResponse($field, $resp) : string return $resp->response; } - if (!isset($getResponFromCollection['itemValue'])) { + if (! isset($getResponFromCollection['itemValue'])) { return $resp->response; } diff --git a/src/Fields/Classes/TextInput.php b/src/Fields/Classes/TextInput.php index 63f46a67..e67be9b0 100644 --- a/src/Fields/Classes/TextInput.php +++ b/src/Fields/Classes/TextInput.php @@ -39,10 +39,10 @@ public static function getOptions() //\Filament\Forms\Components\TextInput::make('options.minLength')->visible(fn(\Closure $get) :bool => $get('options.dateType') === 'numeric'), //\Filament\Forms\Components\TextInput::make('options.maxLength')->visible(fn(\Closure $get) :bool => $get('options.dateType') === 'numeric'), - \Filament\Forms\Components\TextInput::make('options.minValue')->visible(fn(\Closure $get) : bool => $get('options.dateType') === 'numeric'), - \Filament\Forms\Components\TextInput::make('options.maxValue')->visible(fn(\Closure $get) : bool => $get('options.dateType') === 'numeric'), + \Filament\Forms\Components\TextInput::make('options.minValue')->visible(fn (\Closure $get): bool => $get('options.dateType') === 'numeric'), + \Filament\Forms\Components\TextInput::make('options.maxValue')->visible(fn (\Closure $get): bool => $get('options.dateType') === 'numeric'), - \Filament\Forms\Components\TextInput::make('options.length')->hidden(fn(\Closure $get) : bool => in_array($get('options.dateType'), [ 'email', 'url' ])), + \Filament\Forms\Components\TextInput::make('options.length')->hidden(fn (\Closure $get): bool => in_array($get('options.dateType'), ['email', 'url'])), ]; } } diff --git a/src/Filament/Resources/FormResource.php b/src/Filament/Resources/FormResource.php index 9e821f88..f6d2558a 100644 --- a/src/Filament/Resources/FormResource.php +++ b/src/Filament/Resources/FormResource.php @@ -8,11 +8,11 @@ use Filament\Tables\Columns\BooleanColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Filters\Filter; +use Illuminate\Database\Eloquent\Builder; use LaraZeus\Bolt\Filament\Resources\FormResource\Pages; use LaraZeus\Bolt\Filament\Resources\FormResource\Schemata; use LaraZeus\Bolt\Filament\Resources\FormResource\Widgets\BetaNote; use LaraZeus\Bolt\Models\Form as ZeusForm; -use Illuminate\Database\Eloquent\Builder; class FormResource extends BoltResource { @@ -23,42 +23,42 @@ class FormResource extends BoltResource protected static ?int $navigationSort = 1; protected static ?string $recordTitleAttribute = 'name'; - public static function getGloballySearchableAttributes() : array + public static function getGloballySearchableAttributes(): array { - return [ 'name', 'slug' ]; + return ['name', 'slug']; } - protected static function getNavigationBadge() : ?string + protected static function getNavigationBadge(): ?string { return (string) ZeusForm::query()->count(); } - protected static function getNavigationGroup() : ?string + protected static function getNavigationGroup(): ?string { return __('Bolt'); } - public static function getLabel() : string + public static function getLabel(): string { return __('Form'); } - public static function getPluralLabel() : string + public static function getPluralLabel(): string { return __('Forms'); } - protected static function getNavigationLabel() : string + protected static function getNavigationLabel(): string { return __('Forms'); } - public static function form(Form $form) : Form + public static function form(Form $form): Form { return $form->schema(static::getMainFormSchema()); } - public static function table(Table $table) : Table + public static function table(Table $table): Table { return $table ->columns([ @@ -75,13 +75,13 @@ public static function table(Table $table) : Table ->label(__('Entries')) ->icon('clarity-data-cluster-line') ->tooltip(__('view all entries')) - ->url(fn(ZeusForm $record) : string => url('admin/responses?form_id=' . $record->id)), + ->url(fn (ZeusForm $record): string => url('admin/responses?form_id='.$record->id)), Action::make('open') ->label(__('Open')) ->icon('heroicon-o-external-link') ->tooltip(__('open form')) - ->url(fn(ZeusForm $record) : string => route('bolt.user.form.show', $record)) + ->url(fn (ZeusForm $record): string => route('bolt.user.form.show', $record)) ->openUrlInNewTab(), ])->filters([ Filter::make('is_active') @@ -91,7 +91,7 @@ public static function table(Table $table) : Table ]); } - public static function getPages() : array + public static function getPages(): array { return [ 'index' => Pages\ListForms::route('/'), @@ -100,7 +100,7 @@ public static function getPages() : array ]; } - public static function getWidgets() : array + public static function getWidgets(): array { return [ BetaNote::class, diff --git a/src/Filament/Resources/FormResource/Pages/CreateForm.php b/src/Filament/Resources/FormResource/Pages/CreateForm.php index a4ecebc8..4df1abb5 100644 --- a/src/Filament/Resources/FormResource/Pages/CreateForm.php +++ b/src/Filament/Resources/FormResource/Pages/CreateForm.php @@ -2,10 +2,10 @@ namespace LaraZeus\Bolt\Filament\Resources\FormResource\Pages; +use Filament\Pages\Actions; use Filament\Resources\Pages\CreateRecord; use LaraZeus\Bolt\Filament\Resources\FormResource; use LaraZeus\Bolt\Filament\Resources\FormResource\Widgets\BetaNote; -use Filament\Pages\Actions; class CreateForm extends CreateRecord { diff --git a/src/Filament/Resources/FormResource/Pages/EditForm.php b/src/Filament/Resources/FormResource/Pages/EditForm.php index 1352c270..2afb0f49 100644 --- a/src/Filament/Resources/FormResource/Pages/EditForm.php +++ b/src/Filament/Resources/FormResource/Pages/EditForm.php @@ -2,9 +2,9 @@ namespace LaraZeus\Bolt\Filament\Resources\FormResource\Pages; +use Filament\Pages\Actions\Action; use Filament\Pages\Actions\LocaleSwitcher; use Filament\Resources\Pages\EditRecord; -use Filament\Pages\Actions\Action; use LaraZeus\Bolt\Filament\Resources\FormResource; use LaraZeus\Bolt\Filament\Resources\FormResource\Widgets\BetaNote; @@ -22,14 +22,14 @@ protected function getActions(): array ->label(__('Entries')) ->icon('clarity-data-cluster-line') ->tooltip(__('view all entries')) - ->url(fn() => url('admin/responses?form_id=' . $this->record->id)), + ->url(fn () => url('admin/responses?form_id='.$this->record->id)), Action::make('open') ->label(__('Open')) ->icon('heroicon-o-external-link') ->tooltip(__('open form')) ->color('warning') - ->url(fn() => route('bolt.user.form.show', $this->record)) + ->url(fn () => route('bolt.user.form.show', $this->record)) ->openUrlInNewTab(), ]; } diff --git a/src/Filament/Resources/FormResource/Schemata.php b/src/Filament/Resources/FormResource/Schemata.php index 57e8ed89..9c390e52 100644 --- a/src/Filament/Resources/FormResource/Schemata.php +++ b/src/Filament/Resources/FormResource/Schemata.php @@ -4,7 +4,6 @@ use Filament\Forms\Components\Card; use Filament\Forms\Components\DateTimePicker; -use Filament\Forms\Components\Fieldset; use Filament\Forms\Components\Grid; use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Placeholder; @@ -46,7 +45,7 @@ public static function getMainFormSchema(): array ->createItemButtonLabel(__('Add Section')) ->cloneable() ->collapsible() - ->itemLabel(fn(array $state): ?string => $state['name'] ?? null) + ->itemLabel(fn (array $state): ?string => $state['name'] ?? null) ->columnSpan(2), ]; } @@ -171,7 +170,7 @@ public static function getSectionsSchema(): array 'md' => 2, ]) ->label('') - ->itemLabel(fn(array $state): ?string => $state['name'] ?? null) + ->itemLabel(fn (array $state): ?string => $state['name'] ?? null) ->createItemButtonLabel(__('Add field')) ->schema(static::getFieldsSchema()), ]; @@ -211,6 +210,7 @@ public static function getFieldsSchema(): array if (class_exists($class)) { return (new $class)->hasOptions(); } + return false; }) ->schema(function (\Closure $get) { diff --git a/src/Filament/Resources/ResponseResource.php b/src/Filament/Resources/ResponseResource.php index de7ff13f..42778549 100644 --- a/src/Filament/Resources/ResponseResource.php +++ b/src/Filament/Resources/ResponseResource.php @@ -22,7 +22,7 @@ class ResponseResource extends BoltResource protected static function getNavigationBadge(): ?string { - return (string)Response::query()->count(); + return (string) Response::query()->count(); } protected static function getNavigationGroup(): ?string @@ -51,7 +51,7 @@ public static function form(Form $form): Form ->schema([ ViewField::make('response')->view('zeus-bolt::filament.resources.response-resource.components.view-responses') ->label('') - ->columnSpan(2) + ->columnSpan(2), ]); } @@ -64,7 +64,7 @@ public static function table(Table $table): Table TextColumn::make('created_at')->label(__('Created Date')), ]; - if (!request()->filled('form_id')) { + if (! request()->filled('form_id')) { TextColumn::make('form.name')->label(__('form')); } diff --git a/src/Filament/Resources/ResponseResource/Pages/BrowseResponses.php b/src/Filament/Resources/ResponseResource/Pages/BrowseResponses.php index 6365c86a..54887783 100644 --- a/src/Filament/Resources/ResponseResource/Pages/BrowseResponses.php +++ b/src/Filament/Resources/ResponseResource/Pages/BrowseResponses.php @@ -38,7 +38,7 @@ protected function getTableColumns(): array return [ Tables\Columns\ViewColumn::make('response') ->view('zeus-bolt::filament.resources.response-resource.components.view-responses') - ->label('') + ->label(''), ]; } diff --git a/src/Filament/Resources/ResponseResource/Pages/ListResponses.php b/src/Filament/Resources/ResponseResource/Pages/ListResponses.php index 906f676e..8f63d887 100644 --- a/src/Filament/Resources/ResponseResource/Pages/ListResponses.php +++ b/src/Filament/Resources/ResponseResource/Pages/ListResponses.php @@ -2,8 +2,8 @@ namespace LaraZeus\Bolt\Filament\Resources\ResponseResource\Pages; -use Filament\Resources\Pages\ListRecords; use Filament\Pages\Actions\Action; +use Filament\Resources\Pages\ListRecords; use LaraZeus\Bolt\Filament\Resources\FormResource\Widgets\BetaNote; use LaraZeus\Bolt\Filament\Resources\ResponseResource; @@ -23,7 +23,7 @@ protected function getActions(): array return [ Action::make('brows') ->label(__('Brows Entries')) - ->url(fn (): string => 'responses/brows?form_id='.request('form_id')) + ->url(fn (): string => 'responses/brows?form_id='.request('form_id')), ]; } } diff --git a/src/Http/Livewire/FillForms.php b/src/Http/Livewire/FillForms.php index b6524b26..eec944e8 100644 --- a/src/Http/Livewire/FillForms.php +++ b/src/Http/Livewire/FillForms.php @@ -18,16 +18,16 @@ 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()->orderBy('ordering')->get() as $section) { $fields = []; foreach ($section->fields()->orderBy('ordering')->get() as $field) { - $setField = ( new $field->type )->renderClass::make('zeusData.' . $field->id) + $setField = ( new $field->type )->renderClass::make('zeusData.'.$field->id) ->label($field->name) ->id($field->html_id)//->rules(collect($field->rules)->pluck('rule')) - ; +; // todo so ugly change! if (isset($field->description)) { @@ -54,14 +54,14 @@ protected function getFormSchema() : array } } - if($field->type == '\LaraZeus\Bolt\Fields\Classes\FileUpload'){ + if ($field->type == '\LaraZeus\Bolt\Fields\Classes\FileUpload') { $setField ->disk(config('zeus-bolt.uploads.disk')) ->directory(config('zeus-bolt.uploads.directory')); } // todo so ugly change! - $fields[] = Forms\Components\Card::make()->schema([ $setField ]); + $fields[] = Forms\Components\Card::make()->schema([$setField]); } if (optional($this->zeusForm->options)['show-as-wizard']) { @@ -72,22 +72,22 @@ protected function getFormSchema() : array } if (optional($this->zeusForm->options)['show-as-wizard']) { - return [ Wizard::make($sections) ]; + return [Wizard::make($sections)]; } return $sections; } - protected function getFormModel() : Form + protected function getFormModel(): Form { return $this->zeusForm; } public function mount($slug) { - $this->zeusForm = Form::with([ 'sections', 'sections.fields' ])->whereSlug($slug)->whereIsActive(1)->firstOrFail(); + $this->zeusForm = Form::with(['sections', 'sections.fields'])->whereSlug($slug)->whereIsActive(1)->firstOrFail(); - abort_if(optional($this->zeusForm->options)['require-login'] && !auth()->check(), 401); + abort_if(optional($this->zeusForm->options)['require-login'] && ! auth()->check(), 401); foreach ($this->zeusForm->fields as $field) { $this->zeusData[$field->id] = ''; @@ -107,21 +107,21 @@ public function store() $this->validate(); $response = Response::make([ 'form_id' => $this->zeusForm->id, - 'user_id' => ( auth()->check() ) ? auth()->user()->id : null, + 'user_id' => (auth()->check()) ? auth()->user()->id : null, '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() diff --git a/src/Models/FieldResponse.php b/src/Models/FieldResponse.php index be021156..198a89ad 100644 --- a/src/Models/FieldResponse.php +++ b/src/Models/FieldResponse.php @@ -28,7 +28,7 @@ public function field() public function parentResponse() { - return $this->belongsTo(Response::class,'response_id','id'); + return $this->belongsTo(Response::class, 'response_id', 'id'); } public function form()