Skip to content

Commit

Permalink
Merge pull request #21 from lara-zeus/analysis-MPw03l
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
atmonshi authored Sep 11, 2022
2 parents 8144f27 + b9205ec commit 6299744
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 78 deletions.
40 changes: 20 additions & 20 deletions database/seeders/BoltSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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([
Expand All @@ -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([
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -148,81 +148,81 @@ 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([
'form_id' => $form,
'user_id' => null,
'status' => 'NEW',
'notes' => null,
'created_at' => now()
'created_at' => now(),
]);

$response_1_field_1 = DB::table('field_responses')->insertGetId([
'form_id' => $form,
'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' => '[email protected]',
'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([
'form_id' => $form,
'user_id' => 2,
'status' => 'NEW',
'notes' => null,
'created_at' => now()
'created_at' => now(),
]);

$response_2_field_1 = DB::table('field_responses')->insertGetId([
'form_id' => $form,
'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' => '[email protected]',
'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(),
]);
}
}
4 changes: 0 additions & 4 deletions src/Events/FormMounted.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Classes/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Classes/CheckboxList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
5 changes: 2 additions & 3 deletions src/Fields/Classes/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
}
}
2 changes: 1 addition & 1 deletion src/Fields/Classes/MultiSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Classes/Radio.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
4 changes: 2 additions & 2 deletions src/Fields/Classes/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
Expand All @@ -42,7 +42,7 @@ public function getResponse($field, $resp) : string
return $resp->response;
}

if (!isset($getResponFromCollection['itemValue'])) {
if (! isset($getResponFromCollection['itemValue'])) {
return $resp->response;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Fields/Classes/TextInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])),
];
}
}
28 changes: 14 additions & 14 deletions src/Filament/Resources/FormResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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([
Expand All @@ -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')
Expand All @@ -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('/'),
Expand All @@ -100,7 +100,7 @@ public static function getPages() : array
];
}

public static function getWidgets() : array
public static function getWidgets(): array
{
return [
BetaNote::class,
Expand Down
2 changes: 1 addition & 1 deletion src/Filament/Resources/FormResource/Pages/CreateForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Loading

0 comments on commit 6299744

Please sign in to comment.