diff --git a/app/Exports/XlsformExport/XlsformSettingsExport.php b/app/Exports/XlsformExport/XlsformSettingsExport.php index da3406da..21250575 100644 --- a/app/Exports/XlsformExport/XlsformSettingsExport.php +++ b/app/Exports/XlsformExport/XlsformSettingsExport.php @@ -31,7 +31,7 @@ public function collection(): \Illuminate\Support\Collection 'form_id' => $this->xlsform->odk_id ?? Str::slug($this->xlsform->title), 'form_title' => $this->xlsform->title, 'version' => Carbon::now()->toDateTimeString(), - 'instance_name' => 'TO BE UPDATED!!', // TODO: fix + 'instance_name' => '"instance"', // TODO: fix ], ]); diff --git a/app/Exports/XlsformExport/XlsformSurveyExport.php b/app/Exports/XlsformExport/XlsformSurveyExport.php index c3bf9162..121755ef 100644 --- a/app/Exports/XlsformExport/XlsformSurveyExport.php +++ b/app/Exports/XlsformExport/XlsformSurveyExport.php @@ -16,13 +16,15 @@ use Maatwebsite\Excel\Concerns\WithStyles; use Maatwebsite\Excel\Concerns\WithTitle; use Maatwebsite\Excel\Row; +use PhpOffice\PhpSpreadsheet\Style\Fill; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use Stats4sd\FilamentOdkLink\Models\OdkLink\XlsformTemplate; class XlsformSurveyExport implements FromCollection, WithHeadings, WithTitle, WithStyles, ShouldAutoSize, WithColumnWidths { public Collection $surveyRows; - public array $dynamicStyles; + public Collection $dynamicStylesRowLists; + public function __construct(public Xlsform $xlsform, public Collection $xlsformTemplateLanguages, public Collection $languageStringTypes) @@ -33,7 +35,7 @@ public function __construct(public Xlsform $xlsform, public Collection $xlsformT ->sortBy('id') ->load('languageStrings') ->map(function (SurveyRow $row) { - return [ + return collect([ 'id' => $row->id, 'type' => $row->type, 'name' => $row->name, @@ -49,21 +51,12 @@ public function __construct(public Xlsform $xlsform, public Collection $xlsformT ...$this->getLanguageStrings($row, 'constraint_message'), 'choice_filter' => $row->choice_filter, 'repeat_count' => $row->repeat_count, + ...$this->getLanguageStrings($row, 'mediaimage'), 'default' => $row->default, - ]; + ]); }); - $beginGroupRows = $this->surveyRows->filter(fn(SurveyRow $surveyRow) => $surveyRow['type'] === 'begin_group'); - $endGroupRows = $this->surveyRows->filter(fn(SurveyRow $surveyRow) => $surveyRow['type'] === 'end_group'); - $beginRepeatRows = $this->surveyRows->filter(fn(SurveyRow $surveyRow) => $surveyRow['type'] === 'begin_repeat'); - $endRepeatRows = $this->surveyRows->filter(fn(SurveyRow $surveyRow) => $surveyRow['type'] === 'end_repeat'); - - $this->dynamicStyles = [ - ...$beginGroupRows->mapWithKeys(fn(SurveyRow $surveyRow) => [$surveyRow['id'] + 1 => [])->toArray(), - 'end_group' => $endGroupRows->map(fn(SurveyRow $surveyRow) => $surveyRow['id'])->toArray(), - 'begin_repeat' => $beginRepeatRows->map(fn(SurveyRow $surveyRow) => $surveyRow['id'])->toArray(), - 'end_repeat' => $endRepeatRows->map(fn(SurveyRow $surveyRow) => $surveyRow['id'])->toArray(), - ]; + $this->dynamicStyleRowLists = $this->getDynamicStylesRowLists($this->surveyRows); } @@ -88,14 +81,30 @@ public function title(): string private function getLanguageStrings(mixed $row, string $string): Collection { return $this->xlsformTemplateLanguages - ->mapWithKeys(function(XlsformTemplateLanguage $xlsformTemplateLanguage) use ($row, $string) { - $key = "$string::{$xlsformTemplateLanguage->language->name} ({$xlsformTemplateLanguage->language->iso_alpha2})"; - $value = $row->languageStrings - ->where('language_string_type_id', $this->languageStringTypes->where('name', $string)->first()->id) - ->where('xlsform_template_language_id', $xlsformTemplateLanguage->id) - ->first()?->text ?? ''; - - return [$key => $value]; + ->mapWithKeys(function (XlsformTemplateLanguage $xlsformTemplateLanguage) use ($row, $string) { + + // fix for mediaimage needing to be media::image, etc. + $outputString = $string; + + if($string === 'mediaimage') { + $outputString = 'media::image'; + } + + if($string === 'mediaaudio') { + $outputString = 'media::audio'; + } + + if($string === 'mediavideo') { + $outputString = 'media::video'; + } + + $key = "$outputString::{$xlsformTemplateLanguage->language->name} ({$xlsformTemplateLanguage->language->iso_alpha2})"; + $value = $row->languageStrings + ->where('language_string_type_id', $this->languageStringTypes->where('name', $string)->first()->id) + ->where('xlsform_template_language_id', $xlsformTemplateLanguage->id) + ->first()?->text ?? ''; + + return [$key => $value]; }); } @@ -136,21 +145,92 @@ public function columnWidths(): array ]; } - public function styles(Worksheet $sheet): array + public function styles(Worksheet $sheet): void { - // starting at C, make label + hint columns auto-wrap per Xlsformtemplatelangauge - $wrapLabelArray = $this->xlsformTemplateLanguages->mapWithKeys(fn(XlsformTemplateLanguage $language, $index) => [chr(67 + $index) => ['alignment' => ['wrapText' => true]]] - )->toArray(); - $languageCount = $this->xlsformTemplateLanguages->count(); - $wrapHintArray = $this->xlsformTemplateLanguages->mapWithKeys(fn(XlsformTemplateLanguage $language, $index) => [chr(67 + $languageCount + $index) => ['alignment' => ['wrapText' => true]]] - )->toArray(); + $wrapStyle = ['alignment' => ['wrapText' => true]]; - return [ - 1 => ['font' => ['bold' => true]], - ...$wrapLabelArray, - ...$wrapHintArray, + $beginGroupStyle = [ + 'fill' => [ + 'fillType' => Fill::FILL_SOLID, + 'startColor' => ['rgb' => '8ED873',], + 'endColor' => ['rgb' => '8ED873',], + ], + ]; + + $endGroupStyle = [ + 'fill' => [ + 'fillType' => Fill::FILL_SOLID, + 'startColor' => ['rgb' => 'FA8E78',], + 'endColor' => ['rgb' => 'FA8E78',], + ], + ]; + + $beginRepeatStyle = [ + 'fill' => [ + 'fillType' => Fill::FILL_SOLID, + 'startColor' => ['rgb' => '83CAEB',], + 'endColor' => ['rgb' => '83CAEB',], + ], + ]; + + $endRepeatStyle = [ + 'fill' => [ + 'fillType' => Fill::FILL_SOLID, + 'startColor' => ['rgb' => 'E49EDD',], + 'endColor' => ['rgb' => 'E49EDD',], + ], ]; + + + // starting at C, make label + hint columns auto-wrap per Xlsformtemplatelangauge + $wrapLabelList = $this->xlsformTemplateLanguages->map(fn(XlsformTemplateLanguage $language, $index) => chr(67 + $index)); + $wrapHintList = $this->xlsformTemplateLanguages->map(fn(XlsformTemplateLanguage $language, $index) => chr(67 + $languageCount + $index)); + + + // **** APPLY STYLES **** + + $sheet->getStyle('1:1')->getFont()->setBold(true); + + foreach($wrapLabelList as $column) { + $sheet->getStyle($column . ':' . $column)->applyFromArray($wrapStyle); + } + + foreach($wrapHintList as $column) { + $sheet->getStyle($column . ':' . $column)->applyFromArray($wrapStyle); + } + + foreach($this->dynamicStyleRowLists['beginGroupRows'] as $row) { + $sheet->getStyle($row . ':' . $row)->applyFromArray($beginGroupStyle); + } + + foreach($this->dynamicStyleRowLists['endGroupRows'] as $row) { + $sheet->getStyle($row . ':' . $row)->applyFromArray($endGroupStyle); + } + + foreach($this->dynamicStyleRowLists['beginRepeatRows'] as $row) { + $sheet->getStyle($row . ':' . $row)->applyFromArray($beginRepeatStyle); + } + + foreach($this->dynamicStyleRowLists['endRepeatRows'] as $row) { + $sheet->getStyle($row . ':' . $row)->applyFromArray($endRepeatStyle); + } + + } + + private function getDynamicStylesRowLists(Collection $surveyRows): Collection + { + $beginGroupRows = $surveyRows->filter(fn(Collection $surveyRow) => $surveyRow['type'] === 'begin_group')->pluck('id'); + $endGroupRows = $surveyRows->filter(fn(Collection $surveyRow) => $surveyRow['type'] === 'end_group')->pluck('id'); + $beginRepeatRows = $surveyRows->filter(fn(Collection $surveyRow) => $surveyRow['type'] === 'begin_repeat')->pluck('id'); + $endRepeatRows = $surveyRows->filter(fn(Collection $surveyRow) => $surveyRow['type'] === 'end_repeat')->pluck('id'); + + return collect([ + 'beginGroupRows' => $beginGroupRows->map(fn($id) => $id + 1), + 'endGroupRows' => $endGroupRows->map(fn($id) => $id + 1), + 'beginRepeatRows' => $beginRepeatRows->map(fn($id) => $id + 1), + 'endRepeatRows' => $endRepeatRows->map(fn($id) => $id + 1), + ]); } } diff --git a/app/Exports/XlsformExport/XlsformWorkbookExport.php b/app/Exports/XlsformExport/XlsformWorkbookExport.php index 849d7cb0..8e84e21a 100644 --- a/app/Exports/XlsformExport/XlsformWorkbookExport.php +++ b/app/Exports/XlsformExport/XlsformWorkbookExport.php @@ -38,9 +38,6 @@ public function __construct(public Xlsform $xlsform) // get the language string types once to avoid multiple queries $this->languageStringTypes = LanguageStringType::all(); - ray($this->xlsformTemplateLanguages); - ray($this->languageStringTypes); - } public function sheets(): array diff --git a/app/Filament/Admin/Resources/TeamResource/RelationManagers/XlsformsRelationManager.php b/app/Filament/Admin/Resources/TeamResource/RelationManagers/XlsformsRelationManager.php index 838d2f73..8eb02589 100644 --- a/app/Filament/Admin/Resources/TeamResource/RelationManagers/XlsformsRelationManager.php +++ b/app/Filament/Admin/Resources/TeamResource/RelationManagers/XlsformsRelationManager.php @@ -5,24 +5,53 @@ use App\Exports\XlsformExport\XlsformWorkbookExport; use App\Models\Xlsforms\Xlsform; use Filament\Tables\Actions\Action; +use Filament\Tables\Actions\CreateAction; use Filament\Tables\Table; use Maatwebsite\Excel\Facades\Excel; +use Stats4sd\FilamentOdkLink\Jobs\UpdateXlsformTitleInFile; +use Stats4sd\FilamentOdkLink\Services\OdkLinkService; class XlsformsRelationManager extends \Stats4sd\FilamentOdkLink\Filament\Resources\TeamResource\RelationManagers\XlsformsRelationManager { - public function table(Table $table): Table { return parent::table($table) ->actions([ Action::make('download xls file') - ->action(function(Xlsform $record) { - - return Excel::download((new XlsformWorkbookExport($record)), 'xlsform.xlsx'); - - }) + ->action(function (Xlsform $record) { + + return Excel::download((new XlsformWorkbookExport($record)), 'xlsform.xlsx'); + + }), + // add Publish button + Action::make('publish') + ->label('Publish') + ->icon('heroicon-m-arrow-up-tray') + ->requiresConfirmation() + ->action(function (Xlsform $record) { + $odkLinkService = app()->make(OdkLinkService::class); + + // create draft if there is no draft yet + if (!$record->has_draft) { + $odkLinkService->createDraftForm($record); + } + + // call API to publish form in ODK central + $odkLinkService->publishForm($record); + }), + ]) + ->headerActions([ + CreateAction::make() + ->label('Add Xlsform to Team') + ->after(function (Xlsform $record) { + + $odkLinkService = app()->make(OdkLinkService::class); + + $record->refresh(); + $record->deployDraft($odkLinkService); + }), ]); } } diff --git a/app/Filament/Admin/Widgets/DataCollectedWidget.php b/app/Filament/Admin/Widgets/DataCollectedWidget.php index d5ebc129..0d316604 100644 --- a/app/Filament/Admin/Widgets/DataCollectedWidget.php +++ b/app/Filament/Admin/Widgets/DataCollectedWidget.php @@ -2,7 +2,7 @@ namespace App\Filament\Admin\Widgets; -use App\Models\XlsformTemplate; +use App\Models\XlsformTemplates\XlsformTemplate; use App\Models\SampleFrame\Farm; use Illuminate\Support\HtmlString; use Spatie\Permission\Models\Role; diff --git a/app/Filament/App/Clusters/Actions/CreateLookupListEntryAction.php b/app/Filament/App/Clusters/Actions/CreateLookupListEntryAction.php new file mode 100644 index 00000000..d945b81c --- /dev/null +++ b/app/Filament/App/Clusters/Actions/CreateLookupListEntryAction.php @@ -0,0 +1,63 @@ +locales; + + $labelFields = $locales->map(function (Locale $locale) { + return TextInput::make('label_' . $locale->language_id) + ->label('label::' . $locale->language_label); + }); + + $this->form([ + TextInput::make('name')->required(), + ...$labelFields->toArray(), + ]); + + // add the current team as owner + if (Filament::hasTenancy()) { + $this->mutateFormDataUsing( + function (array $data): array { + + $locales = HelperService::getSelectedTeam()?->locales; + return collect($data) + // don't include the 'label' entries - we will create languageStrings after creating the ChoiceListEntry + ->filter(fn($value, $key) => !Str::startsWith($key, 'label_')) + ->put('owner_id', Filament::getTenant()->id) + ->put('owner_type', get_class(Filament::getTenant())) + ->toArray(); + }) + ->after(function (ChoiceListEntry $record, array $data) { + $locales = HelperService::getSelectedTeam()?->locales; + + dd($data); + + $languageStrings = $locales->map(function (Locale $locale) use ($record, $data) { + $xlsformTemplateLanguage = $record->xlsformTemplate->xlsformTemplateLanguages()->where('language_id', $locale->language_id)->first(); + + return [ + 'xlsform_template_language_id' => $xlsformTemplateLanguage->id, + 'language_string_type_id' => 1, // hardcoded to labels. TODO: fix; + 'text' => $data, + ]; + }); + }); + } + + } +} diff --git a/app/Filament/App/Clusters/LookupTables.php b/app/Filament/App/Clusters/LookupTables.php new file mode 100644 index 00000000..22cbb3fd --- /dev/null +++ b/app/Filament/App/Clusters/LookupTables.php @@ -0,0 +1,12 @@ +modifyQueryUsing(fn (Builder $query) => $query + ->whereHas('choiceList', fn(Builder $query) => $query + ->where('choice_lists.list_name', $this->choiceListName) + ) + ); + } + + protected function getHeaderWidgets(): array + { + return [ + ChoiceListEntryResource\Widgets\ChoiceListEntriesInfo::make(['choiceListName' => $this->choiceListName]), + ]; + } + + protected function getHeaderActions(): array + { + return [ + CreateAction::make() + ->label('Add ' . $this->choiceListName), + +// Action::make('Mark as Complete') +// ->requiresConfirmation() +// ->action(fn () => HelperService::getSelectedTeam()?->markLookupListAsComplete(AnimalProduct::getLinkedDataset())) +// ->visible(fn () => ! HelperService::getSelectedTeam()?->hasCompletedLookupList(AnimalProduct::getLinkedDataset())), +// +// Action::make('Mark as Incomplete') +// ->requiresConfirmation() +// ->action(fn () => HelperService::getSelectedTeam()?->markLookupListAsIncomplete(AnimalProduct::getLinkedDataset())) +// ->visible(fn () => HelperService::getSelectedTeam()?->hasCompletedLookupList(AnimalProduct::getLinkedDataset())), + + ]; + } +} diff --git a/app/Filament/App/Clusters/LookupTables/Resources/ChoiceListEntryResource.php b/app/Filament/App/Clusters/LookupTables/Resources/ChoiceListEntryResource.php new file mode 100644 index 00000000..8f18f5f3 --- /dev/null +++ b/app/Filament/App/Clusters/LookupTables/Resources/ChoiceListEntryResource.php @@ -0,0 +1,203 @@ +where(fn(Builder $query) => $query + ->whereHasMorph('owner', [Team::class], fn(Builder $query) => $query + ->where('teams.id', HelperService::getSelectedTeam()?->id + )) + ->orWhere('owner_id', null) + ) + // only localisable lists + ->whereHas('choiceList', fn(Builder $query) => $query + ->where('is_localisable', true) + ) + // and only entries that are not linked to lists that are datasets + ->whereDoesntHave('choiceList', fn(Builder $query) => $query + ->where('is_dataset', true) + ); + + } + + + public static function getNavigationItems(): array + { + /** @var Collection $lists */ + $lists = ChoiceList::where('is_localisable', true) + ->where('is_dataset', false) + ->get(); + + return $lists + ->map(fn(ChoiceList $choiceList) => NavigationItem::make($choiceList->list_name) + ->group('Choice Lists') + ->icon(static::getNavigationIcon()) + ->activeIcon(static::getActiveNavigationIcon()) + ->isActiveWhen(fn() => request()->routeIs(static::getRouteBaseName() . '.*') + && request()->get('list') === $choiceList->list_name + ) + ->badge(static::getNavigationBadge(), color: static::getNavigationBadgeColor()) + ->badgeTooltip(static::getNavigationBadgeTooltip()) + ->sort(static::getNavigationSort()) + ->url(static::getNavigationUrl() . '?' . http_build_query(['choiceListName' => $choiceList->list_name])) + )->toArray(); + } + + public static function form(Form $form): Form + { + $locales = HelperService::getSelectedTeam()?->locales; + + $labelFields = $locales->map(function (Locale $locale) { + return TextInput::make('label_' . $locale->language_id) + ->label('label::' . $locale->language_label); + }); + + + return $form + ->columns(1) + ->schema([ + Hidden::make('choice_list_id') + ->formatStateUsing(fn(?ChoiceListEntry $record, ListChoiceListEntries $livewire) => $record ? $record->choiceList->id : ChoiceList::firstWhere('list_name', $livewire->choiceListName)->id), + TextInput::make('name')->required(), + Repeater::make('languageStrings') + ->label('Add Labels for the following languages:') + ->relationship('languageStrings') + ->minItems(fn() => HelperService::getSelectedTeam()?->locales->count()) + ->maxItems(fn() => HelperService::getSelectedTeam()?->locales->count()) + ->formatStateUsing(function (?ChoiceListEntry $record, $state, ListChoiceListEntries $livewire) { + if ($record) { + return $state; + } + + $locales = HelperService::getSelectedTeam()?->locales; + + $choiceList = ChoiceList::where('list_name', $livewire->choiceListName)->firstOrFail(); + $xlsformTemplateLanguages = $choiceList->xlsformTemplate->xlsformTemplateLanguages; + + return $locales->map(fn(Locale $locale) => [ + 'language_string_type_id' => LanguageStringType::where('name', 'label')->firstOrFail()->id, + 'xlsform_template_language_id' => $xlsformTemplateLanguages->where('language_id', $locale->language_id)->firstOrFail()->id, + 'text' => '', + ])->toArray(); + }) + ->schema([ + Hidden::make('xlsform_template_language_id'), + Hidden::make('language_string_type_id'), + TextInput::make('text') + ->label(function (Get $get) { + $xlsformTemplateLanguage = XlsformTemplateLanguage::find($get('xlsform_template_language_id')); + + return 'Label::'.$xlsformTemplateLanguage?->locale_language_label; + }) + ->required(), + ]) + ->addable(false) + ->deletable(false), + ]); + } + + public static function table(Table $table): Table + { + // languages?? + $locales = HelperService::getSelectedTeam()?->locales; + + $labelColumns = $locales->map(function (Locale $locale) { + return TextColumn::make('label_' . $locale->language->id) + ->label('label::' . $locale->language_label) + ->state(function(ChoiceListEntry $record) use ($locale) { + + + + return $record->languageStrings + // only labels + ->filter(fn(LanguageString $languageString) => $languageString->language_string_type_id === LanguageStringType::where('name', 'label')->firstOrFail()->id) + // only ones for the current locale + ->where('xlsform_template_language_id', XlsformTemplateLanguage::where('language_id', $locale->language_id)->firstOrFail()->id) + ->first() + ?->text ?? ''; + }); + }); + + return $table + ->columns([ + TextColumn::make('choiceList.list_name')->label('list_name'), + TextColumn::make('name')->label('name'), + ...$labelColumns->toArray(), + IconColumn::make('is_global_entry') + ->label('Global Entry') + ->boolean(), + ]) + ->actions([ + EditAction::make()->visible(fn(ChoiceListEntry $record) => $record->is_global_entry), + DeleteAction::make()->visible(fn(ChoiceListEntry $record) => $record->is_global_entry), + Action::make('Toggle Removed') + ->visible(fn(ChoiceListEntry $record) => !$record->is_global_entry && $record->choiceList->can_be_hidden_from_context) + ->action(fn(ChoiceListEntry $record) => $record->toggleRemoved(HelperService::getSelectedTeam())), + ]); + } + + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListChoiceListEntries::route('/'), + ]; + } +} diff --git a/app/Filament/App/Clusters/LookupTables/Resources/ChoiceListEntryResource/Widgets/ChoiceListEntriesInfo.php b/app/Filament/App/Clusters/LookupTables/Resources/ChoiceListEntryResource/Widgets/ChoiceListEntriesInfo.php new file mode 100644 index 00000000..717762f7 --- /dev/null +++ b/app/Filament/App/Clusters/LookupTables/Resources/ChoiceListEntryResource/Widgets/ChoiceListEntriesInfo.php @@ -0,0 +1,45 @@ +refreshSurveyRows(); + } + + #[On('updated:choiceListName')] + protected function refreshSurveyRows(): void + { + + /** @var Collection $surveyRows */ + $this->surveyRows = SurveyRow::query() + ->whereLike('type', 'select_multiple ' . $this->choiceListName) + ->orWhereLike('type', 'select_one ' . $this->choiceListName) + ->get() + ->map(fn(SurveyRow $surveyRow): array => [ + 'name' => $surveyRow->name, + 'label' => $surveyRow->languageStrings() + ->whereHas('xlsformTemplateLanguage', fn(Builder $query) => $query->where('language_id', 41)) + ->where('language_string_type_id', 1) + ->first()?->text ?? 'tbc', + ]); + + ray($this->choiceListName, $this->surveyRows->toArray()); + } +} diff --git a/app/Filament/App/Pages/TeamOdkView.php b/app/Filament/App/Pages/TeamOdkView.php index e17f195e..b06f9a04 100644 --- a/app/Filament/App/Pages/TeamOdkView.php +++ b/app/Filament/App/Pages/TeamOdkView.php @@ -7,7 +7,6 @@ use App\Models\Team; use App\Services\HelperService; use Awcodes\Shout\Components\Shout; -use Filament\Actions\Action; use Filament\Forms\Concerns\InteractsWithForms; use Filament\Infolists\Components\ViewEntry; use Filament\Infolists\Concerns\InteractsWithInfolists; @@ -22,7 +21,10 @@ use Filament\Tables\Table; use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Support\HtmlString; -use Stats4sd\FilamentOdkLink\Models\OdkLink\Xlsform; +use Stats4sd\FilamentOdkLink\Models\OdkLink\Entity; +use Stats4sd\FilamentOdkLink\Models\OdkLink\Submission; +use App\Models\Xlsforms\Xlsform; +use Stats4sd\FilamentOdkLink\Models\OdkLink\XlsformVersion; use Stats4sd\FilamentOdkLink\Services\OdkLinkService; class TeamOdkView extends Page implements HasTable, HasInfolists @@ -94,24 +96,62 @@ public function table(Table $table): Table TextColumn::make('live_submissions_count') ->label('No. of Submissions'), + TextColumn::make('submissions_count') + ->label('Submissions in database') + ->counts('submissions'), ]) ->filters([ // ]) ->headerActions([ - \Filament\Tables\Actions\Action::make('create-temp') + TableAction::make('create-temp') ->color('gray') ->label('Add a new ODK form') ->modalFooterActions([ - Action::make('ok') + TableAction::make('ok') ->label('Return') - ->close() + ->close(), ]) ->form([ Shout::make('note') ->type('danger') - ->content('TBC: Note - at present this feature is not available. All team forms are centrally managed by the system administrators in collaboration with the team leaders. In the future, this will allow teams to have multiple HOLPA survey forms active at the same time, for example a standard HOLPA and a "HOLPA National" survey, or 2 surveys to allow conducting Steps 1 and 2 at different times.') - ]) + ->content('TBC: Note - at present this feature is not available. All team forms are centrally managed by the system administrators in collaboration with the team leaders. In the future, this will allow teams to have multiple HOLPA survey forms active at the same time, for example a standard HOLPA and a "HOLPA National" survey, or 2 surveys to allow conducting Steps 1 and 2 at different times.'), + ]), + TableAction::make('delete_submissions') + ->label('TESTING ONLY: DELETE ALL SUBMISSIONS FROM DATABASE') + ->action(function () { + HelperService::getSelectedTeam()->xlsforms->each(function (Xlsform $xlsform) { + + + // All temporary code... + $xlsform->submissions->each(function (Submission $submission) { + // delete all entities linked to submission; + $submission->entities + ->filter(fn(Entity $entity) => $entity->parent_id !== null ) + ->each(function (Entity $entity) { + + $entity->values()->delete(); + $entity->delete(); + }); + + $submission->entities + ->filter(fn(Entity $entity) => $entity->parent_id === null ) + ->each(function (Entity $entity) { + $entity->values()->delete(); + $entity->delete(); + }); + $submission->forceDelete(); + }); + }); + + $this->resetTable(); + + Notification::make('update_success') + ->title('Success!') + ->body("All submissions have been deleted from the database.") + ->color('success') + ->send(); + }), ]) ->actions([ @@ -171,7 +211,21 @@ public function table(Table $table): Table ->body("The form {$record->title} now has the latest lookup data entered into the platform by your team.") ->color('success') ->send(); - }) + }), + + TableAction::make('pull-submissions') + ->label('Manually Get Submissions') + ->action(function (Xlsform $record) { + $submissionCount = $record->getSubmissions(); + + + $record->refresh(); + Notification::make('update_success') + ->title('Success!') + ->body("{$submissionCount} submissions have been pulled from the ODK server for the form {$record->title} (they may take a moment to process).") + ->color('success') + ->send(); + }), // // // add Pull Submissions button // TableAction::make('export') diff --git a/app/Filament/Traits/IsLookupListResource.php b/app/Filament/Traits/IsLookupListResource.php new file mode 100644 index 00000000..6b295d74 --- /dev/null +++ b/app/Filament/Traits/IsLookupListResource.php @@ -0,0 +1,139 @@ +where(function (Builder $query) { + $query->where('owner_id', null) + ->orWhereHasMorph('owner', Team::class, fn (Builder $query): Builder => $query->whereKey(Filament::getTenant()->id)); + }); + } + + public static function form(Form $form): Form + { + + $extraFields = static::getExtraFormFields(); + + return $form + ->schema([ + TextInput::make('name') + ->required() + ->unique() + ->label('Enter a unique code.') + ->validationMessages([ + 'required' => 'Please enter a unique code', + 'unique' => 'This code is already in use. Please enter a unique code.', + ]) + ->readOnly(fn (LookupListEntry $record) => $record->isGlobal()) + ->helperText('If you are familiar with ODK Form development, this corresponds to the "name" attribute of the element in the XForm.'), + TextInput::make('label') + ->required() + ->label('Enter a label. This is what enumerators will see in the survey.') + ->readOnly(fn (LookupListEntry $record) => $record->isGlobal()) + ->helperText('At present, this platform only supports additional choice options in English. Multiple language support will come soon!'), + ...$extraFields, + ]); + } + + // overwrite this in the main Resource if you want to enable editing of global entries + public static function canEditGlobalItems(): bool + { + return false; + } + + // standard table + public static function table(Table $table): Table + { + $actions = [ + EditAction::make()->visible(fn (LookupListEntry $record): bool => !$record->isGlobal() || static::canEditGlobalItems()), + DeleteAction::make()->visible(fn (LookupListEntry $record): bool => !$record->isGlobal()), + ]; + + if (static::getModel()::canBeHiddenFromContext()) { + $actions[] = Action::make('Toggle Removed') + ->visible(fn (LookupListEntry $record): bool => $record->isGlobal()) + ->label(fn (LookupListEntry $record): string => $record->isRemoved(HelperService::getSelectedTeam()) ? 'Restore to Context' : 'Remove from Context') + ->action(fn (LookupListEntry $record) => $record->toggleRemoved(HelperService::getSelectedTeam())); + } + + return $table + ->columns([ + TextColumn::make('name') + ->label('Unique Code') + ->sortable() + ->searchable(), + TextColumn::make('label') + ->sortable() + ->searchable(), + IconColumn::make('is_customised_entry') + ->label('Is custom entry?') + ->boolean(), + ]) + ->filters([ + TernaryFilter::make('custom') + ->label('Show custom entries?') + ->queries( + true: fn (Builder $query): Builder => $query->whereHasMorph('owner', Team::class), + false: fn (Builder $query): Builder => $query->where('owner_id', null), + ) + ]) + ->actions($actions) + ->defaultPaginationPageOption('all') + ->defaultSort('label', 'asc'); + } + + public static function getNavigationBadge(): ?string + { + $team = HelperService::getSelectedTeam(); + if ($team?->hasCompletedLookupList(self::getModel()::getLinkedDataset())) { + return 'Complete'; + } + + return 'In Progress'; + + } + + public static function getNavigationBadgeColor(): string|array|null + { + $team = HelperService::getSelectedTeam(); + + if ($team?->hasCompletedLookupList(self::getModel()::getLinkedDataset())) { + return 'success'; + } + + return 'info'; + } + + // override this in the model if you need to add extra fields to the form + private static function getExtraFormFields(): array + { + return []; + } + +} diff --git a/app/Http/Controllers/SurveyMonitoringController.php b/app/Http/Controllers/SurveyMonitoringController.php index 3e573912..65e25598 100644 --- a/app/Http/Controllers/SurveyMonitoringController.php +++ b/app/Http/Controllers/SurveyMonitoringController.php @@ -38,6 +38,11 @@ public function getSubmissionSummary(Team $team, string $isTest) return [ 'count' => 0, 'latestSubmissionDate' => null, + 'successfulSurveys' => 0, + 'beneficiaryFarmsSurveyed' => 0, + 'nonBeneficiaryFarmsSurveyed' => 0, + 'surveysWithoutRespondentPresent' => 0, + 'surveysWithNonConsentingRespondent' => 0, ]; } @@ -112,7 +117,7 @@ public function getFormAndLinkService(Team $team, $isTest): array { $xlsform = $team->xlsforms->where('is_test', $isTest)->first(); $odkLinkService = app()->make(OdkLinkService::class); - return array($xlsform, $odkLinkService); + return [$xlsform, $odkLinkService]; } /** diff --git a/app/Imports/XlsformTemplate/XlsformTemplateLanguageStringImport.php b/app/Imports/XlsformTemplate/XlsformTemplateLanguageStringImport.php index 04ba7c22..202e3211 100644 --- a/app/Imports/XlsformTemplate/XlsformTemplateLanguageStringImport.php +++ b/app/Imports/XlsformTemplate/XlsformTemplateLanguageStringImport.php @@ -33,7 +33,6 @@ class XlsformTemplateLanguageStringImport implements WithMultipleSheets, ShouldQ public LanguageStringType $languageStringType; public ?string $class; public ?string $relationship; - public ?string $class; public function __construct(public XlsformTemplate $xlsformTemplate, public string $heading, public string $sheet) { @@ -106,7 +105,7 @@ public function model(array $row): ?LanguageString if (!$item) { - ray('No item found for row', $row, $class); + return null; } $translatableValue = $row @@ -115,6 +114,12 @@ public function model(array $row): ?LanguageString ->first(); if (!$translatableValue) { + + if($this->heading === 'labelenglish_en') { + ray('oh'); + ray($row); + } + return null; } diff --git a/app/Models/Locale.php b/app/Models/Locale.php index 83995208..bd67cb94 100644 --- a/app/Models/Locale.php +++ b/app/Models/Locale.php @@ -13,7 +13,6 @@ class Locale extends Model { - use HasFactory; public function language(): BelongsTo { @@ -56,4 +55,4 @@ public function getStatusAttribute() } } -} \ No newline at end of file +} diff --git a/app/Models/LookupTables/Animal.php b/app/Models/LookupTables/Animal.php deleted file mode 100644 index 07d7b7ee..00000000 --- a/app/Models/LookupTables/Animal.php +++ /dev/null @@ -1,38 +0,0 @@ -isRemoved($team) ? 0 : 1; - } else { - $isRelevant = null; - } - - return [ - 'id' => $this->id, - 'name' => $this->name, - 'label' => $this->label, - 'is_in_context' => $isRelevant, - 'raised_max' => $this->raised_max, - 'breeds_max' => $this->breeds_max, - 'born_max' => $this->born_max, - 'died_max' => $this->died_max, - 'slaughtered_max' => $this->slaughtered_max, - 'purchased_max' => $this->purchased_max, - 'sold_max' => $this->sold_max, - 'farmgate_max' => $this->farmgate_max, - 'given_max' => $this->given_max, - 'expenditures_feed_max' => $this->expenditures_feed_max, - 'expenditures_vet_max' => $this->expenditures_vet_max, - ]; - } -} diff --git a/app/Models/LookupTables/AnimalProduct.php b/app/Models/LookupTables/AnimalProduct.php deleted file mode 100644 index 1fc450f8..00000000 --- a/app/Models/LookupTables/AnimalProduct.php +++ /dev/null @@ -1,32 +0,0 @@ -isRemoved($team) ? 0 : 1; - } else { - $isRelevant = null; - } - - return [ - 'id' => $this->id, - 'name' => $this->name, - 'label' => $this->label, - 'is_in_context' => $isRelevant, - 'total_max' => $this->total_max, - 'unit_default' => $this->unit_default, - 'quantity_sold_max' => $this->quantity_sold_max, - 'farmgate_max' => $this->farmgate_max, - 'quantity_given_max' => $this->quantity_given_max, - ]; - } -} diff --git a/app/Models/LookupTables/Crop.php b/app/Models/LookupTables/Crop.php index ac8d2a96..acf7ec41 100644 --- a/app/Models/LookupTables/Crop.php +++ b/app/Models/LookupTables/Crop.php @@ -9,6 +9,8 @@ class Crop extends LookupEntry { use CanBeHiddenFromContext; + protected $table = 'crop_list_entries'; + public function getCsvContentsForOdk(?WithXlsforms $team = null): array { if ($team) { @@ -22,12 +24,6 @@ public function getCsvContentsForOdk(?WithXlsforms $team = null): array 'name' => $this->name, 'label' => $this->label, 'is_in_context' => $isRelevant, - 'total_max' => $this->total_max, - 'sold_max' => $this->sold_max, - 'farmgate_max' => $this->farmgate_max, - 'gift_max' => $this->gift_max, - 'land_use_max' => $this->land_use_max, - 'varieties_max' => $this->varieties_max, ]; } } diff --git a/app/Models/LookupTables/CropProduct.php b/app/Models/LookupTables/CropProduct.php deleted file mode 100644 index c6b207e8..00000000 --- a/app/Models/LookupTables/CropProduct.php +++ /dev/null @@ -1,32 +0,0 @@ -isRemoved($team) ? 0 : 1; - } else { - $isRelevant = null; - } - - return [ - 'id' => $this->id, - 'name' => $this->name, - 'label' => $this->label, - 'is_in_context' => $isRelevant, - 'total_max' => $this->total_max, - 'unit_default' => $this->unit_default, - 'sold_max' => $this->sold_max, - 'farmgate_max' => $this->farmgate_max, - 'given_max' => $this->given_max, - ]; - } -} diff --git a/app/Models/LookupTables/Enumerator.php b/app/Models/LookupTables/Enumerator.php deleted file mode 100644 index 5ee03138..00000000 --- a/app/Models/LookupTables/Enumerator.php +++ /dev/null @@ -1,17 +0,0 @@ - $this->id, - 'name' => $this->name, - 'label' => $this->label, - ]; - } -} diff --git a/app/Models/LookupTables/Unit.php b/app/Models/LookupTables/Unit.php deleted file mode 100644 index 41cbf7dc..00000000 --- a/app/Models/LookupTables/Unit.php +++ /dev/null @@ -1,27 +0,0 @@ -belongsTo(UnitType::class); - } - - public function getCsvContentsForOdk(?WithXlsforms $team = null): array - { - return [ - 'id' => $this->id, - 'unit_type_id' => $this->unitType?->id, - 'unit_type_name' => $this->unitType?->name, - 'name' => $this->name, - 'label' => $this->label, - 'conversion_rate' => $this->conversion_rate, - ]; - } -} diff --git a/app/Models/Reference/AgPractice.php b/app/Models/Reference/AgPractice.php new file mode 100644 index 00000000..0dbfabde --- /dev/null +++ b/app/Models/Reference/AgPractice.php @@ -0,0 +1,16 @@ +belongsTo(AgPracticeGroup::class); + } +} diff --git a/app/Models/Reference/AgPracticeGroup.php b/app/Models/Reference/AgPracticeGroup.php new file mode 100644 index 00000000..99ed6da2 --- /dev/null +++ b/app/Models/Reference/AgPracticeGroup.php @@ -0,0 +1,21 @@ +hasMany(AgPractice::class); + } + + public function climateMitigationScores(): HasMany + { + return $this->hasMany(ClimateMitigationScore::class); + } +} diff --git a/app/Models/Reference/ClimateMitigationScore.php b/app/Models/Reference/ClimateMitigationScore.php new file mode 100644 index 00000000..3ff280eb --- /dev/null +++ b/app/Models/Reference/ClimateMitigationScore.php @@ -0,0 +1,21 @@ +belongsTo(AgPractice::class); + } + + public function region(): BelongsTo + { + return $this->belongsTo(Region::class); + } +} diff --git a/app/Models/Reference/Continent.php b/app/Models/Reference/Continent.php new file mode 100644 index 00000000..a777ac37 --- /dev/null +++ b/app/Models/Reference/Continent.php @@ -0,0 +1,25 @@ +hasMany(Region::class); + } + + public function countries(): HasManyThrough + { + return $this->hasManyThrough(Country::class, Region::class); + } + +} diff --git a/app/Models/Reference/Country.php b/app/Models/Reference/Country.php new file mode 100644 index 00000000..5bd0996b --- /dev/null +++ b/app/Models/Reference/Country.php @@ -0,0 +1,24 @@ +belongsTo(Region::class); + } + + public function continent(): \Znck\Eloquent\Relations\BelongsToThrough + { + return $this->belongsToThrough(Continent::class, Region::class); + } +} diff --git a/app/Models/Reference/Currency.php b/app/Models/Reference/Currency.php new file mode 100644 index 00000000..6a71dd9b --- /dev/null +++ b/app/Models/Reference/Currency.php @@ -0,0 +1,16 @@ +hasMany(ExchangeRate::class); + } +} diff --git a/app/Models/Reference/ExchangeRate.php b/app/Models/Reference/ExchangeRate.php new file mode 100644 index 00000000..14f26470 --- /dev/null +++ b/app/Models/Reference/ExchangeRate.php @@ -0,0 +1,16 @@ +belongsTo(Currency::class); + } +} diff --git a/app/Models/Reference/GniEntry.php b/app/Models/Reference/GniEntry.php new file mode 100644 index 00000000..d9c70191 --- /dev/null +++ b/app/Models/Reference/GniEntry.php @@ -0,0 +1,21 @@ +belongsTo(Country::class); + } + + public function currency(): BelongsTo + { + return $this->belongsTo(Currency::class); + } +} diff --git a/app/Models/Reference/Region.php b/app/Models/Reference/Region.php new file mode 100644 index 00000000..fbc0469b --- /dev/null +++ b/app/Models/Reference/Region.php @@ -0,0 +1,38 @@ +hasMany(Country::class); + } + + public function continent(): BelongsTo + { + return $this->belongsTo(Continent::class); + } + + public function parent(): BelongsTo + { + return $this->belongsTo(self::class, 'parent_id'); + } + + public function children(): HasMany + { + return $this->hasMany(self::class, 'parent_id'); + } + + +} diff --git a/app/Models/Team.php b/app/Models/Team.php index ce41a9f7..f509bc76 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -4,6 +4,7 @@ use App\Models\Locale; use App\Models\SampleFrame\Farm; +use Illuminate\Database\Eloquent\Builder; use Spatie\MediaLibrary\HasMedia; use App\Models\SampleFrame\Location; use App\Models\SampleFrame\LocationLevel; @@ -40,24 +41,12 @@ protected static function booted(): void $owner->createLinkedOdkProject($odkLinkService, $owner); } - // create empty interpretation entries for the team: - // TODO: this probably is not great, and we should not require a bunch of empty entries! + // all teams get a default locale of english + $en = Locale::whereHas('language', fn(Builder $query) => $query->where('iso_alpha2', 'en'))->first(); - // Below are tape-data-system specific business logic, HOPLA may have something similar. - // Temporary keep it for reference first. We can remove them after confirming we do not need them. + $owner->locales()->attach($en); - /* - $interpretations = CaetIndex::all()->map(fn ($index) => [ - 'owner_id' => $owner->id, - 'owner_type' => static::class, - 'caet_index_id' => $index->id, - 'interpretation' => '', - ])->toArray(); - $owner->caetInterpretations()->createMany($interpretations); - - $owner->locationLevels()->create(['name' => 'Top level (rename)', 'has_farms' => 0, 'top_level' => 1, 'slug' =>'site-level']); - */ }); } @@ -95,4 +84,30 @@ public function xlsforms(): MorphMany { return $this->morphMany(Xlsform::class, 'owner'); } + + public function lookupTables(): BelongsToMany + { + return $this->belongsToMany(Dataset::class, 'team_lookup_tables', 'team_id', 'lookup_table_id') + ->withPivot('is_complete') + ->where('lookup_table', true); + } + + public function markLookupListAsComplete($lookupTable): ?bool + { + $this->lookupTables()->sync([$lookupTable->id => ['is_complete' => 1]], detaching: false); + + return $this->hasCompletedLookupList($lookupTable); + } + + public function markLookupListAsInComplete($lookupTable): ?bool + { + $this->lookupTables()->detach($lookupTable->id); + + return $this->hasCompletedLookupList($lookupTable); + } + + public function hasCompletedLookupList($lookupTable): ?bool + { + return $this->lookupTables->where('id', $lookupTable->id)->first()?->pivot->is_complete; + } } diff --git a/app/Models/Traits/CanBeHiddenFromContext.php b/app/Models/Traits/CanBeHiddenFromContext.php index 2ad06e35..153d1f7b 100644 --- a/app/Models/Traits/CanBeHiddenFromContext.php +++ b/app/Models/Traits/CanBeHiddenFromContext.php @@ -10,14 +10,14 @@ // Trait to use on LookupEntry models when the user can remove 'global' entries from their own context. E.g. For Crops - a user can remove a crop from their own context, and so it will not show in the shortened list of crops in the ODK form. (but will appear in the full list if the enumerator selects "other"... trait CanBeHiddenFromContext { - public static function canBeHiddenFromContext(): bool + public function canBeHiddenFromContext(): bool { - return true; + return $this->choiceList->can_be_hidden_from_context; } public function teamRemoved(): BelongsToMany { - return $this->BelongsToMany(Team::class, Str::snake(class_basename($this)) . '_team_removed'); + return $this->BelongsToMany(Team::class, 'choice_list_entries_removed'); } public function isRemoved(WithXlsforms $team): bool diff --git a/app/Models/XlsformTemplates/ChoiceList.php b/app/Models/XlsformTemplates/ChoiceList.php index 8172df20..705b0f95 100644 --- a/app/Models/XlsformTemplates/ChoiceList.php +++ b/app/Models/XlsformTemplates/ChoiceList.php @@ -3,7 +3,9 @@ namespace App\Models\XlsformTemplates; use App\Models\Traits\IsLookupList; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; class ChoiceList extends Model @@ -12,6 +14,7 @@ class ChoiceList extends Model protected $casts = [ 'properties' => 'collection', + 'can_be_hidden_from_context' => 'boolean', ]; public function choiceListEntries(): HasMany @@ -19,5 +22,8 @@ public function choiceListEntries(): HasMany return $this->hasMany(ChoiceListEntry::class); } - + public function xlsformTemplate(): BelongsTo + { + return $this->belongsTo(XlsformTemplate::class); + } } diff --git a/app/Models/XlsformTemplates/ChoiceListEntry.php b/app/Models/XlsformTemplates/ChoiceListEntry.php index 6bd3d42b..429b50f5 100644 --- a/app/Models/XlsformTemplates/ChoiceListEntry.php +++ b/app/Models/XlsformTemplates/ChoiceListEntry.php @@ -3,15 +3,20 @@ namespace App\Models\XlsformTemplates; use App\Models\HasLanguageStrings; +use App\Models\Traits\CanBeHiddenFromContext; use App\Models\Traits\IsLookupList; +use Dom\Attr; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphMany; +use Znck\Eloquent\Relations\BelongsToThrough; class ChoiceListEntry extends Model implements HasLanguageStrings { use IsLookupList; - + use CanBeHiddenFromContext; + use \Znck\Eloquent\Traits\BelongsToThrough; protected $casts = [ 'is_localisable' => 'boolean', @@ -25,6 +30,11 @@ public function choiceList(): BelongsTo return $this->belongsTo(ChoiceList::class); } + public function xlsformTemplate(): BelongsToThrough + { + return $this->belongsToThrough(XlsformTemplate::class, ChoiceList::class); + } + public function languageStrings(): MorphMany { return $this->morphMany(LanguageString::class, 'linked_entry'); diff --git a/app/Models/XlsformTemplates/LanguageString.php b/app/Models/XlsformTemplates/LanguageString.php index 80ad058e..be2817dc 100644 --- a/app/Models/XlsformTemplates/LanguageString.php +++ b/app/Models/XlsformTemplates/LanguageString.php @@ -2,6 +2,7 @@ namespace App\Models\XlsformTemplates; +use App\Models\Language; use App\Models\LanguageStringType; use App\Models\XlsformTemplateLanguage; use Illuminate\Database\Eloquent\Model; @@ -12,6 +13,8 @@ class LanguageString extends Model { + use \Znck\Eloquent\Traits\BelongsToThrough; + protected $casts = [ 'updated_during_import' => 'boolean', ]; @@ -36,4 +39,9 @@ public function xlsformTemplate(): BelongsToThrough { return $this->belongsToThrough(XlsformTemplate::class, XlsformTemplateLanguage::class); } + + public function language(): BelongsToThrough + { + return $this->belongsToThrough(Language::class, XlsformTemplateLanguage::class); + } } diff --git a/app/Models/Xlsforms/Xlsform.php b/app/Models/Xlsforms/Xlsform.php index 182e36d0..5f0d369f 100644 --- a/app/Models/Xlsforms/Xlsform.php +++ b/app/Models/Xlsforms/Xlsform.php @@ -31,8 +31,6 @@ public function formSurveyRows(): HasMany public function syncWithTemplate(): void { - // no need to copy over file... - // if the odk_project is not set, set it based on the given owner: $this->odk_project_id = $this->owner->odkProject->id; $this->has_latest_template = true; @@ -52,7 +50,10 @@ public function deployDraft(OdkLinkService $service): bool $filePath = 'temp/' . $this->id . '/' . $this->title . '.xlsx'; Excel::store(new XlsformWorkbookExport($this), $filePath, 'local'); - $this->addMedia($filePath)->toMediaCollection('xlsform_file'); + $this->addMediaFromDisk($filePath, disk: 'local')->toMediaCollection('xlsform_file'); + + $this->syncWithTemplate(); + UpdateXlsformTitleInFile::dispatchSync($this); return parent::deployDraft($service); } diff --git a/app/Providers/Filament/AppPanelProvider.php b/app/Providers/Filament/AppPanelProvider.php index bc6908de..403790f0 100644 --- a/app/Providers/Filament/AppPanelProvider.php +++ b/app/Providers/Filament/AppPanelProvider.php @@ -58,6 +58,7 @@ public function panel(Panel $panel): Panel ->discoverPages(in: app_path('Filament/App/Pages'), for: 'App\\Filament\\App\\Pages') // to include role register, program register, register filament pages from package stats4sd/filament-team-management ->discoverPages(in: app_path('../vendor/stats4sd/filament-team-management/src/Filament/App/Pages'), for: 'Stats4sd\\FilamentTeamManagement\\Filament\\App\\Pages') + ->discoverClusters(in: app_path('Filament/App/Clusters'), for: 'App\\Filament\\App\\Clusters') ->pages([ SurveyDashboard::class, TeamOdkView::class, diff --git a/composer.json b/composer.json index 8ac39c6b..b9fd229b 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "shiftonelabs/laravel-cascade-deletes": "^2.0", "stats4sd/filament-odk-link": "dev-main", "stats4sd/filament-team-management": "^1.0", + "stats4sd/laravel-sql-views": "^1.2", "staudenmeir/belongs-to-through": "^2.16", "symfony/http-client": "^7.1", "symfony/mailgun-mailer": "^7.1", diff --git a/composer.lock b/composer.lock index 8d732121..5c77c55a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "58c3940cc4bdcfa0ec52943081b7a739", + "content-hash": "a8564be43c17ea2b8f22c9365313d783", "packages": [ { "name": "althinect/filament-spatie-roles-permissions", @@ -7666,6 +7666,65 @@ ], "time": "2024-11-21T16:05:20+00:00" }, + { + "name": "stats4sd/laravel-sql-views", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/stats4sd/laravel-sql-views.git", + "reference": "d3771a6df8c7cbd2cca7803503d056d8014e09ae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/stats4sd/laravel-sql-views/zipball/d3771a6df8c7cbd2cca7803503d056d8014e09ae", + "reference": "d3771a6df8c7cbd2cca7803503d056d8014e09ae", + "shasum": "" + }, + "require-dev": { + "mockery/mockery": "^1.1", + "orchestra/testbench": "~3|~4", + "phpunit/phpunit": "^8.0", + "sempro/phpunit-pretty-print": "^1.0" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "SqlViews": "Stats4SD\\SqlViews\\Facades\\SqlViews" + }, + "providers": [ + "Stats4SD\\SqlViews\\SqlViewsServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Stats4SD\\SqlViews\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Stats4SD", + "email": "support@stats4sd.org", + "homepage": "https://stats4sd.org" + } + ], + "description": "A small package to help automate the creation and updating of MySQL views within a Laravel project.", + "homepage": "https://github.com/stats4sd/laravel-sql-views", + "keywords": [ + "laravel", + "sql" + ], + "support": { + "issues": "https://github.com/stats4sd/laravel-sql-views/issues", + "source": "https://github.com/stats4sd/laravel-sql-views/tree/v1.2.0" + }, + "time": "2023-10-12T11:06:09+00:00" + }, { "name": "staudenmeir/belongs-to-through", "version": "v2.16.2", @@ -14589,6 +14648,6 @@ "platform": { "php": "^8.2" }, - "platform-dev": [], + "platform-dev": {}, "plugin-api-version": "2.6.0" } diff --git a/database/migrations/2024_11_13_124055_create_choices_table.php b/database/migrations/2024_11_13_124055_create_choices_table.php index 9108ca26..cfb0c69e 100644 --- a/database/migrations/2024_11_13_124055_create_choices_table.php +++ b/database/migrations/2024_11_13_124055_create_choices_table.php @@ -18,7 +18,7 @@ public function up(): void // entries might be global; or localised (localised ones have an owner) $table->nullableMorphs('owner'); $table->string('name'); - $table->json('properties'); + $table->json('properties')->nullable(); $table->timestamps(); }); } diff --git a/database/migrations/2024_12_12_121439_create_team_lookup_tables.php b/database/migrations/2024_12_12_121439_create_team_lookup_tables.php new file mode 100644 index 00000000..cdcd1463 --- /dev/null +++ b/database/migrations/2024_12_12_121439_create_team_lookup_tables.php @@ -0,0 +1,30 @@ +id(); + $table->foreignId('team_id')->constrained()->cascadeOnDelete(); + $table->foreignId('lookup_table_id')->constrained('datasets', 'id')->cascadeOnDelete(); + $table->boolean('is_complete')->default(false); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('team_lookup_tables'); + } +}; diff --git a/database/migrations/2024_12_12_144802_create_choice_list_entries_removed_table.php b/database/migrations/2024_12_12_144802_create_choice_list_entries_removed_table.php new file mode 100644 index 00000000..397b96c6 --- /dev/null +++ b/database/migrations/2024_12_12_144802_create_choice_list_entries_removed_table.php @@ -0,0 +1,29 @@ +id(); + $table->foreignId('choice_list_entry_id')->constrained(); + $table->foreignId('team_id')->constrained(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('choice_list_entries_removed'); + } +}; diff --git a/database/migrations/2024_12_12_145053_add_can_be_hidden_from_context_to_choice_lists_table.php b/database/migrations/2024_12_12_145053_add_can_be_hidden_from_context_to_choice_lists_table.php new file mode 100644 index 00000000..8d862162 --- /dev/null +++ b/database/migrations/2024_12_12_145053_add_can_be_hidden_from_context_to_choice_lists_table.php @@ -0,0 +1,28 @@ +boolean('can_be_hidden_from_context')->default(0)->after('is_dataset'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('choice_lists', function (Blueprint $table) { + // + }); + } +}; diff --git a/database/migrations/2024_12_13_09327_create_practices_tables.php b/database/migrations/2024_12_13_09327_create_practices_tables.php new file mode 100644 index 00000000..f394f23d --- /dev/null +++ b/database/migrations/2024_12_13_09327_create_practices_tables.php @@ -0,0 +1,37 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + + Schema::create('ag_practices', function (Blueprint $table) { + $table->id(); + $table->foreignId('ag_practice_group_id')->constrained(); + $table->string('name'); + $table->timestamps(); + }); + } + + + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('practices_tables'); + } +}; diff --git a/database/migrations/2024_12_13_09329_create_currencies_table.php b/database/migrations/2024_12_13_09329_create_currencies_table.php new file mode 100644 index 00000000..4cfa7e8c --- /dev/null +++ b/database/migrations/2024_12_13_09329_create_currencies_table.php @@ -0,0 +1,29 @@ +string('id')->primary()->comment('3 character ISO code'); + $table->string('name'); + $table->timestamps(); + }); + + + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('currencies'); + } +}; diff --git a/database/migrations/2024_12_13_104400_create_m49_regions_tables.php b/database/migrations/2024_12_13_104400_create_m49_regions_tables.php new file mode 100644 index 00000000..e5bc4d38 --- /dev/null +++ b/database/migrations/2024_12_13_104400_create_m49_regions_tables.php @@ -0,0 +1,45 @@ +string('id')->primary(); // m49 code + $table->string('name'); + $table->timestamps(); + }); + + Schema::create('regions', function (Blueprint $table) { + $table->string('id')->primary(); // m49 code + $table->string('continent_id')->constrained('continents'); + $table->string('parent_id')->nullable()->constrained('regions'); + $table->string('name'); + $table->timestamps(); + }); + + Schema::create('countries', function (Blueprint $table) { + $table->string('id')->primary(); + $table->string('region_id')->constrained('regions'); + $table->string('iso_alpha2', 2); + $table->string('iso_alpha3', 3); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('countries'); + } +}; diff --git a/database/migrations/2024_12_13_105433_create_crop_list_entries_table.php b/database/migrations/2024_12_13_105433_create_crop_list_entries_table.php new file mode 100644 index 00000000..2d6f89f6 --- /dev/null +++ b/database/migrations/2024_12_13_105433_create_crop_list_entries_table.php @@ -0,0 +1,32 @@ +id(); + + $table->foreignId('choice_list_entry_id')->constrained('choice_list_entries'); + $table->decimal('expected_yield', 20, 2)->nullable()->comment('Must be in KG/HA. Used for calculating KPI12'); + $table->decimal('recommended_fert_use', 20, 2)->nullable()->comment('must be in KG/HA.'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('crop_list_entries'); + } +}; diff --git a/database/migrations/2024_12_13_105755_create_climate_mitigation_scores_table.php b/database/migrations/2024_12_13_105755_create_climate_mitigation_scores_table.php new file mode 100644 index 00000000..923622a1 --- /dev/null +++ b/database/migrations/2024_12_13_105755_create_climate_mitigation_scores_table.php @@ -0,0 +1,30 @@ +id(); + $table->string('region_id')->constrained('regions'); + $table->foreignId('ag_practice_id')->constrained('ag_practices'); + $table->decimal('score', 10, 4); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('climate_mitigation_scores'); + } +}; diff --git a/database/migrations/2024_12_13_105832_create_gni_table.php b/database/migrations/2024_12_13_105832_create_gni_table.php new file mode 100644 index 00000000..10e83242 --- /dev/null +++ b/database/migrations/2024_12_13_105832_create_gni_table.php @@ -0,0 +1,31 @@ +id(); + $table->string('country_id')->constrained('countries'); + $table->string('currency_id')->constrained('currencies'); + $table->year('year'); + $table->decimal('gni', 30, 10); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('gni'); + } +}; diff --git a/database/migrations/2024_12_13_105857_create_exchange_rates_table.php b/database/migrations/2024_12_13_105857_create_exchange_rates_table.php new file mode 100644 index 00000000..241a474a --- /dev/null +++ b/database/migrations/2024_12_13_105857_create_exchange_rates_table.php @@ -0,0 +1,31 @@ +id(); + $table->string('from_currency_id')->constrained('currencies')->onDelete('cascade'); + $table->string('to_currency_id')->constrained('currencies')->onDelete('cascade') + ->default('USD'); + $table->date('date'); + $table->decimal('rate', 10, 4); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('currency_conversions'); + } +}; diff --git a/database/procedures/example-proc.sql b/database/procedures/example-proc.sql new file mode 100644 index 00000000..c03ff4b5 --- /dev/null +++ b/database/procedures/example-proc.sql @@ -0,0 +1,9 @@ +DROP PROCEDURE IF EXISTS `multiply`; + +CREATE PROCEDURE `multiply` (IN num_one INT, IN num_two INT, OUT result INT) + +BEGIN + +SET result = num_one * num_two; + +END diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 22bc6ef2..4623e81b 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -16,6 +16,7 @@ public function run(): void { // ODK Platform setup $this->call(PlatformSeeder::class); + $this->call(Un49LocationSeeder::class); // call the prep seeders always. foreach (glob(database_path('seeders/Prep/*.php')) as $file) { @@ -30,5 +31,6 @@ public function run(): void $this->call($class); } } + } } diff --git a/database/seeders/Prep/AgPracticeSeeder.php b/database/seeders/Prep/AgPracticeSeeder.php new file mode 100644 index 00000000..9219194c --- /dev/null +++ b/database/seeders/Prep/AgPracticeSeeder.php @@ -0,0 +1,62 @@ + 'Cropping Systems']); + $riceGroup = AgPracticeGroup::create(['name' => 'Lowland Rice Systems']); + $livestockGroup = AgPracticeGroup::create(['name' => 'Livestock Systems']); + $fishGroup = AgPracticeGroup::create(['name' => 'Fish Systems']); + + $cropGroup->agPractices()->createMany([ + ['name' => 'Monocultures annual',], + ['name' => 'Monocultures perennial',], + ['name' => 'Agroforestry',], + ['name' => 'Vegetation clearance',], + ['name' => 'Green manure',], + ['name' => 'Crop rotation',], + ['name' => 'Embedded natural (hedgerows) - fallow',], + ['name' => 'Embedded natural (hedgerows) - hedgerows',], + ['name' => 'Homegarden',], + ['name' => 'Intercropping',], + ['name' => 'Vegetation clearance',], + ['name' => 'Mulching',], + ['name' => 'Embedded natural (hedgerows) - natural strips/vegetation',], + ['name' => 'Embedded natural (hedgerows) - pollinator strips',], + ['name' => 'Push-Pull',], + ['name' => 'Other',], + ['name' => 'Biochar',], + ['name' => 'Drip irrigation',], + ['name' => 'Microdosing',], + ['name' => 'Reduced tillage',], + ]); + + $riceGroup->agPractices()->createMany([ + ['name' => 'Rice_Biochar',], + ['name' => 'Rice_Green manure',], + ['name' => 'Rice_Microdosing',], + ['name' => 'Rice-fish integration',], + ['name' => 'Alternate wetting and drying',], + ]); + + $livestockGroup->agPractices()->createMany([ + ['name' => 'Improved feed quality'], + ['name' => 'Planting N-fixing legumes'], + ['name' => 'Rotational grazing'], + ]); + + $fishGroup->agPractices()->createMany([ + ['name' => 'Improved feed quality'], + ]); + } +} diff --git a/database/seeders/Prep/ClimateMitigationScoreSeeder.php b/database/seeders/Prep/ClimateMitigationScoreSeeder.php new file mode 100644 index 00000000..fc00c2d2 --- /dev/null +++ b/database/seeders/Prep/ClimateMitigationScoreSeeder.php @@ -0,0 +1,165 @@ + '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Monocultures annual')->id, + 'score' => 2.666666667, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Monocultures perennial')->id, + 'score' => 3.833333333, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Agroforestry')->id, + 'score' => 4.66, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Vegetation clearance')->id, + 'score' => 1.666666667, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Green manure')->id, + 'score' => 3.0, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Crop rotation')->id, + 'score' => 3.0, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Embedded natural (hedgerows) - fallow')->id, + 'score' => 4.33, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Embedded natural (hedgerows) - hedgerows')->id, + 'score' => 4.33, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Homegarden')->id, + 'score' => 4.66, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Intercropping')->id, + 'score' => 4.33, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Vegetation clearance')->id, + 'score' => 1.666666667, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Mulching')->id, + 'score' => 3.33, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Embedded natural (hedgerows) - natural strips/vegetation')->id, + 'score' => 4.33, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Embedded natural (hedgerows) - pollinator strips')->id, + 'score' => 4.33, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Push-Pull')->id, + 'score' => 4.33, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Other')->id, + 'score' => 3.630888889, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Biochar')->id, + 'score' => 2.66, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Drip irrigation')->id, + 'score' => 2.66, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Microdosing')->id, + 'score' => 2.66, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Reduced tillage')->id, + 'score' => 3.66, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Rice_Biochar')->id, + 'score' => 3.33, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Rice_Green manure')->id, + 'score' => 4.0, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Rice_Microdosing')->id, + 'score' => 3.33, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Rice-fish integration')->id, + 'score' => 3.33, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Alternate wetting and drying')->id, + 'score' => 3.33, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Improved feed quality')->id, + 'score' => 4.0, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Planting N-fixing legumes')->id, + 'score' => 3.33, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Rotational grazing')->id, + 'score' => 3.33, + ]); + ClimateMitigationScore::create([ + 'region_id' => '202', + 'ag_practice_id' => AgPractice::firstWhere('name', 'Improved feed quality')->id, + 'score' => 3.0, + ]); + + } +} diff --git a/database/seeders/Prep/CurrencySeeder.php b/database/seeders/Prep/CurrencySeeder.php new file mode 100644 index 00000000..e847bbbf --- /dev/null +++ b/database/seeders/Prep/CurrencySeeder.php @@ -0,0 +1,187 @@ + 'AED', 'name' => 'UAE Dirham']); + Currency::create(['id' => 'AFN', 'name' => 'Afghani']); + Currency::create(['id' => 'ALL', 'name' => 'Lek']); + Currency::create(['id' => 'AMD', 'name' => 'Armenian Dram']); + Currency::create(['id' => 'ANG', 'name' => 'Netherlands Antillean Guilder']); + Currency::create(['id' => 'AOA', 'name' => 'Kwanza']); + Currency::create(['id' => 'ARS', 'name' => 'Argentine Peso']); + Currency::create(['id' => 'AUD', 'name' => 'Australian Dollar']); + Currency::create(['id' => 'AWG', 'name' => 'Aruban Florin']); + Currency::create(['id' => 'AZN', 'name' => 'Azerbaijanian Manat']); + Currency::create(['id' => 'BAM', 'name' => 'Convertible Mark']); + Currency::create(['id' => 'BBD', 'name' => 'Barbados Dollar']); + Currency::create(['id' => 'BDT', 'name' => 'Taka']); + Currency::create(['id' => 'BGN', 'name' => 'Bulgarian Lev']); + Currency::create(['id' => 'BHD', 'name' => 'Bahraini Dinar']); + Currency::create(['id' => 'BIF', 'name' => 'Burundi Franc']); + Currency::create(['id' => 'BMD', 'name' => 'Bermudian Dollar']); + Currency::create(['id' => 'BND', 'name' => 'Brunei Dollar']); + Currency::create(['id' => 'BOB', 'name' => 'Boliviano']); + Currency::create(['id' => 'BOV', 'name' => 'Mvdol']); + Currency::create(['id' => 'BRL', 'name' => 'Brazilian Real']); + Currency::create(['id' => 'BSD', 'name' => 'Bahamian Dollar']); + Currency::create(['id' => 'BTN', 'name' => 'Ngultrum']); + Currency::create(['id' => 'BWP', 'name' => 'Pula']); + Currency::create(['id' => 'BYN', 'name' => 'Belarussian Ruble']); + Currency::create(['id' => 'BZD', 'name' => 'Belize Dollar']); + Currency::create(['id' => 'CAD', 'name' => 'Canadian Dollar']); + Currency::create(['id' => 'CDF', 'name' => 'Congolese Franc']); + Currency::create(['id' => 'CHE', 'name' => 'WIR Euro']); + Currency::create(['id' => 'CHF', 'name' => 'Swiss Franc']); + Currency::create(['id' => 'CHW', 'name' => 'WIR Franc']); + Currency::create(['id' => 'CLF', 'name' => 'Unidad de Fomento']); + Currency::create(['id' => 'CLP', 'name' => 'Chilean Peso']); + Currency::create(['id' => 'CNY', 'name' => 'Chinese Yuan']); + Currency::create(['id' => 'COP', 'name' => 'Colombian Peso']); + Currency::create(['id' => 'COU', 'name' => 'Unidad de Valor Real']); + Currency::create(['id' => 'CRC', 'name' => 'Costa Rican Colon']); + Currency::create(['id' => 'CUC', 'name' => 'Peso Convertible']); + Currency::create(['id' => 'CUP', 'name' => 'Cuban Peso']); + Currency::create(['id' => 'CVE', 'name' => 'Cabo Verde Escudo']); + Currency::create(['id' => 'CZK', 'name' => 'Czech Koruna']); + Currency::create(['id' => 'DJF', 'name' => 'Djibouti Franc']); + Currency::create(['id' => 'DKK', 'name' => 'Danish Krone']); + Currency::create(['id' => 'DOP', 'name' => 'Dominican Peso']); + Currency::create(['id' => 'DZD', 'name' => 'Algerian Dinar']); + Currency::create(['id' => 'EGP', 'name' => 'Egyptian Pound']); + Currency::create(['id' => 'ERN', 'name' => 'Nakfa']); + Currency::create(['id' => 'ETB', 'name' => 'Ethiopian Birr']); + Currency::create(['id' => 'EUR', 'name' => 'Euro']); + Currency::create(['id' => 'FJD', 'name' => 'Fiji Dollar']); + Currency::create(['id' => 'FKP', 'name' => 'Falkland Islands Pound']); + Currency::create(['id' => 'GBP', 'name' => 'Pound Sterling']); + Currency::create(['id' => 'GEL', 'name' => 'Lari']); + Currency::create(['id' => 'GHS', 'name' => 'Ghana Cedi']); + Currency::create(['id' => 'GIP', 'name' => 'Gibraltar Pound']); + Currency::create(['id' => 'GMD', 'name' => 'Dalasi']); + Currency::create(['id' => 'GNF', 'name' => 'Guinea Franc']); + Currency::create(['id' => 'GTQ', 'name' => 'Quetzal']); + Currency::create(['id' => 'GYD', 'name' => 'Guyana Dollar']); + Currency::create(['id' => 'HKD', 'name' => 'Hong Kong Dollar']); + Currency::create(['id' => 'HNL', 'name' => 'Lempira']); + Currency::create(['id' => 'HTG', 'name' => 'Gourde']); + Currency::create(['id' => 'HUF', 'name' => 'Forint']); + Currency::create(['id' => 'IDR', 'name' => 'Rupiah']); + Currency::create(['id' => 'ILS', 'name' => 'New Israeli Sheqel']); + Currency::create(['id' => 'INR', 'name' => 'Indian Rupee']); + Currency::create(['id' => 'IQD', 'name' => 'Iraqi Dinar']); + Currency::create(['id' => 'IRR', 'name' => 'Iranian Rial']); + Currency::create(['id' => 'ISK', 'name' => 'Iceland Krona']); + Currency::create(['id' => 'JMD', 'name' => 'Jamaican Dollar']); + Currency::create(['id' => 'JOD', 'name' => 'Jordanian Dinar']); + Currency::create(['id' => 'JPY', 'name' => 'Yen']); + Currency::create(['id' => 'KES', 'name' => 'Kenyan Shilling']); + Currency::create(['id' => 'KGS', 'name' => 'Som']); + Currency::create(['id' => 'KHR', 'name' => 'Riel']); + Currency::create(['id' => 'KMF', 'name' => 'Comoro Franc']); + Currency::create(['id' => 'KPW', 'name' => 'North Korean Won']); + Currency::create(['id' => 'KRW', 'name' => 'Won']); + Currency::create(['id' => 'KWD', 'name' => 'Kuwaiti Dinar']); + Currency::create(['id' => 'KYD', 'name' => 'Cayman Islands Dollar']); + Currency::create(['id' => 'KZT', 'name' => 'Tenge']); + Currency::create(['id' => 'LAK', 'name' => 'Kip']); + Currency::create(['id' => 'LBP', 'name' => 'Lebanese Pound']); + Currency::create(['id' => 'LKR', 'name' => 'Sri Lanka Rupee']); + Currency::create(['id' => 'LRD', 'name' => 'Liberian Dollar']); + Currency::create(['id' => 'LSL', 'name' => 'Loti']); + Currency::create(['id' => 'LYD', 'name' => 'Libyan Dinar']); + Currency::create(['id' => 'MAD', 'name' => 'Moroccan Dirham']); + Currency::create(['id' => 'MDL', 'name' => 'Moldovan Leu']); + Currency::create(['id' => 'MGA', 'name' => 'Malagasy Ariary']); + Currency::create(['id' => 'MKD', 'name' => 'Denar']); + Currency::create(['id' => 'MMK', 'name' => 'Kyat']); + Currency::create(['id' => 'MNT', 'name' => 'Tugrik']); + Currency::create(['id' => 'MOP', 'name' => 'Pataca']); + Currency::create(['id' => 'MRU', 'name' => 'Ouguiya']); + Currency::create(['id' => 'MUR', 'name' => 'Mauritius Rupee']); + Currency::create(['id' => 'MVR', 'name' => 'Rufiyaa']); + Currency::create(['id' => 'MWK', 'name' => 'Kwacha']); + Currency::create(['id' => 'MXN', 'name' => 'Mexican Peso']); + Currency::create(['id' => 'MXV', 'name' => 'Mexican Unidad de Inversion (UDI)']); + Currency::create(['id' => 'MYR', 'name' => 'Malaysian Ringgit']); + Currency::create(['id' => 'MZN', 'name' => 'Mozambique Metical']); + Currency::create(['id' => 'NAD', 'name' => 'Namibia Dollar']); + Currency::create(['id' => 'NGN', 'name' => 'Naira']); + Currency::create(['id' => 'NIO', 'name' => 'Cordoba Oro']); + Currency::create(['id' => 'NOK', 'name' => 'Norwegian Krone']); + Currency::create(['id' => 'NPR', 'name' => 'Nepalese Rupee']); + Currency::create(['id' => 'NZD', 'name' => 'new Zealand Dollar']); + Currency::create(['id' => 'OMR', 'name' => 'Rial Omani']); + Currency::create(['id' => 'PAB', 'name' => 'Balboa']); + Currency::create(['id' => 'PEN', 'name' => 'Nuevo Sol']); + Currency::create(['id' => 'PGK', 'name' => 'Kina']); + Currency::create(['id' => 'PHP', 'name' => 'Philippine Peso']); + Currency::create(['id' => 'PKR', 'name' => 'Pakistan Rupee']); + Currency::create(['id' => 'PLN', 'name' => 'Zloty']); + Currency::create(['id' => 'PYG', 'name' => 'Guarani']); + Currency::create(['id' => 'QAR', 'name' => 'Qatari Rial']); + Currency::create(['id' => 'RON', 'name' => 'Romanian Leu']); + Currency::create(['id' => 'RSD', 'name' => 'Serbian Dinar']); + Currency::create(['id' => 'RUB', 'name' => 'Russian Ruble']); + Currency::create(['id' => 'RWF', 'name' => 'Rwanda Franc']); + Currency::create(['id' => 'SAR', 'name' => 'Saudi Riyal']); + Currency::create(['id' => 'SBD', 'name' => 'Solomon Islands Dollar']); + Currency::create(['id' => 'SCR', 'name' => 'Seychelles Rupee']); + Currency::create(['id' => 'SDG', 'name' => 'Sudanese Pound']); + Currency::create(['id' => 'SEK', 'name' => 'Swedish Krona']); + Currency::create(['id' => 'SGD', 'name' => 'Singapore Dollar']); + Currency::create(['id' => 'SHP', 'name' => 'Saint Helena Pound']); + Currency::create(['id' => 'SLE', 'name' => 'Leone']); + Currency::create(['id' => 'SOM', 'name' => 'Kyrgyz Som']); + Currency::create(['id' => 'SOS', 'name' => 'Somali Shilling']); + Currency::create(['id' => 'SRD', 'name' => 'Surinam Dollar']); + Currency::create(['id' => 'SSP', 'name' => 'South Sudanese Pound']); + Currency::create(['id' => 'STN', 'name' => 'Dobra']); + Currency::create(['id' => 'SVC', 'name' => 'El Salvador Colon']); + Currency::create(['id' => 'SYP', 'name' => 'Syrian Pound']); + Currency::create(['id' => 'SZL', 'name' => 'Lilangeni']); + Currency::create(['id' => 'THB', 'name' => 'Baht']); + Currency::create(['id' => 'TJS', 'name' => 'Somoni']); + Currency::create(['id' => 'TMT', 'name' => 'Turkmenistan New Manat']); + Currency::create(['id' => 'TND', 'name' => 'Tunisian Dinar']); + Currency::create(['id' => 'TOP', 'name' => 'Pa’anga']); + Currency::create(['id' => 'TRY', 'name' => 'Turkish Lira']); + Currency::create(['id' => 'TTD', 'name' => 'Trinidad and Tobago Dollar']); + Currency::create(['id' => 'TWD', 'name' => 'new Taiwan Dollar']); + Currency::create(['id' => 'TZS', 'name' => 'Tanzanian Shilling']); + Currency::create(['id' => 'UAH', 'name' => 'Hryvnia']); + Currency::create(['id' => 'UGX', 'name' => 'Uganda Shilling']); + Currency::create(['id' => 'USD', 'name' => 'US Dollar']); + Currency::create(['id' => 'USN', 'name' => 'US Dollar(Next day)']); + Currency::create(['id' => 'UYI', 'name' => 'Uruguay Peso en Unidades Indexadas ()']); + Currency::create(['id' => 'UYU', 'name' => 'Peso Uruguayo']); + Currency::create(['id' => 'UZS', 'name' => 'Uzbekistan Sum']); + Currency::create(['id' => 'VEF', 'name' => 'bolivar fuerte']); + Currency::create(['id' => 'VES', 'name' => 'sovereign bolivar']); + Currency::create(['id' => 'VND', 'name' => 'Dong']); + Currency::create(['id' => 'VUV', 'name' => 'Vatu']); + Currency::create(['id' => 'WST', 'name' => 'Tala']); + Currency::create(['id' => 'XAF', 'name' => 'Central African CFA Franc']); + Currency::create(['id' => 'XCD', 'name' => 'East Caribbean Dollar']); + Currency::create(['id' => 'XDR', 'name' => 'SDR (Special Drawing Right)']); + Currency::create(['id' => 'XOF', 'name' => 'West African CFA Franc']); + Currency::create(['id' => 'XPF', 'name' => 'CFP Franc']); + Currency::create(['id' => 'XSU', 'name' => 'Sucre']); + Currency::create(['id' => 'XUA', 'name' => 'ADB Unit of Account']); + Currency::create(['id' => 'YER', 'name' => 'Yemeni Rial']); + Currency::create(['id' => 'ZAR', 'name' => 'Rand']); + Currency::create(['id' => 'ZMW', 'name' => 'Zambian Kwacha']); + Currency::create(['id' => 'ZWL', 'name' => 'Zimbabwe Dollar']); + + } +} diff --git a/database/seeders/Prep/GniSeeder.php b/database/seeders/Prep/GniSeeder.php new file mode 100644 index 00000000..9c9e8d81 --- /dev/null +++ b/database/seeders/Prep/GniSeeder.php @@ -0,0 +1,218 @@ + 'AFG', 'currency_id' => 'AFN', 'gni' => 31298.0878543636, 'year' => '2022']); + GniEntry::create(['country_id' => 'ALB', 'currency_id' => 'ALL', 'gni' => 831076.335920395, 'year' => '2023']); + GniEntry::create(['country_id' => 'DZA', 'currency_id' => 'DZD', 'gni' => 704422.935074139, 'year' => '2023']); + GniEntry::create(['country_id' => 'AND', 'currency_id' => 'EUR', 'gni' => 44206.229955903, 'year' => '2022']); + GniEntry::create(['country_id' => 'AGO', 'currency_id' => 'AOA', 'gni' => 1534747.47246512, 'year' => '2023']); + GniEntry::create(['country_id' => 'ATG', 'currency_id' => 'XCD', 'gni' => 55550.1707353284, 'year' => '2023']); + GniEntry::create(['country_id' => 'ARG', 'currency_id' => 'ARS', 'gni' => 3977266.42865456, 'year' => '2023']); + GniEntry::create(['country_id' => 'ARM', 'currency_id' => 'AMD', 'gni' => 3329631.57902267, 'year' => '2023']); + GniEntry::create(['country_id' => 'ABW', 'currency_id' => 'AWG', 'gni' => 57544.1544714739, 'year' => '2022']); + GniEntry::create(['country_id' => 'AUS', 'currency_id' => 'AUD', 'gni' => 92169.4894435672, 'year' => '2023']); + GniEntry::create(['country_id' => 'AUT', 'currency_id' => 'EUR', 'gni' => 52097.879600538, 'year' => '2023']); + GniEntry::create(['country_id' => 'AZE', 'currency_id' => 'AZN', 'gni' => 11625.8454070213, 'year' => '2023']); + GniEntry::create(['country_id' => 'BHS', 'currency_id' => 'BSD', 'gni' => 33024.4856505733, 'year' => '2023']); + GniEntry::create(['country_id' => 'BHR', 'currency_id' => 'BHD', 'gni' => 10291.4758510383, 'year' => '2023']); + GniEntry::create(['country_id' => 'BGD', 'currency_id' => 'BDT', 'gni' => 270018.131203766, 'year' => '2023']); + GniEntry::create(['country_id' => 'BRB', 'currency_id' => 'BBD', 'gni' => 43451.5802735045, 'year' => '2023']); + GniEntry::create(['country_id' => 'BLR', 'currency_id' => 'BYN', 'gni' => 22692.7573352924, 'year' => '2023']); + GniEntry::create(['country_id' => 'BEL', 'currency_id' => 'EUR', 'gni' => 50535.853158346, 'year' => '2023']); + GniEntry::create(['country_id' => 'BLZ', 'currency_id' => 'BZD', 'gni' => 15434.1854317532, 'year' => '2023']); + GniEntry::create(['country_id' => 'BEN', 'currency_id' => 'XOF', 'gni' => 864883.317438241, 'year' => '2023']); + GniEntry::create(['country_id' => 'BMU', 'currency_id' => 'BMD', 'gni' => 129751.364100951, 'year' => '2022']); + GniEntry::create(['country_id' => 'BTN', 'currency_id' => 'BTN', 'gni' => 276027.326917035, 'year' => '2022']); + GniEntry::create(['country_id' => 'BOL', 'currency_id' => 'BOB', 'gni' => 25012.8450592205, 'year' => '2023']); + GniEntry::create(['country_id' => 'BIH', 'currency_id' => 'BAM', 'gni' => 15205.6817406747, 'year' => '2023']); + GniEntry::create(['country_id' => 'BWA', 'currency_id' => 'BWP', 'gni' => 97339.1307520891, 'year' => '2023']); + GniEntry::create(['country_id' => 'BRA', 'currency_id' => 'BRL', 'gni' => 48705.3171397943, 'year' => '2023']); + GniEntry::create(['country_id' => 'BRN', 'currency_id' => 'BND', 'gni' => 45476.262032511, 'year' => '2023']); + GniEntry::create(['country_id' => 'BGR', 'currency_id' => 'BGN', 'gni' => 27609.6311411583, 'year' => '2023']); + GniEntry::create(['country_id' => 'BFA', 'currency_id' => 'XOF', 'gni' => 508305.869115177, 'year' => '2023']); + GniEntry::create(['country_id' => 'BDI', 'currency_id' => 'BIF', 'gni' => 690108.082662169, 'year' => '2023']); + GniEntry::create(['country_id' => 'CPV', 'currency_id' => 'CVE', 'gni' => 438994.447970709, 'year' => '2023']); + GniEntry::create(['country_id' => 'KHM', 'currency_id' => 'KHR', 'gni' => 7476492.5008088, 'year' => '2023']); + GniEntry::create(['country_id' => 'CMR', 'currency_id' => 'XAF', 'gni' => 994177.567733887, 'year' => '2023']); + GniEntry::create(['country_id' => 'CAN', 'currency_id' => 'CAD', 'gni' => 71013.3914958494, 'year' => '2023']); + GniEntry::create(['country_id' => 'CYM', 'currency_id' => 'KYD', 'gni' => 56512.2056362487, 'year' => '2022']); + GniEntry::create(['country_id' => 'CAF', 'currency_id' => 'XAF', 'gni' => 285895.791409372, 'year' => '2023']); + GniEntry::create(['country_id' => 'TCD', 'currency_id' => 'XAF', 'gni' => 429961.635944347, 'year' => '2023']); + GniEntry::create(['country_id' => 'CHL', 'currency_id' => 'CLP', 'gni' => 13628368.3471942, 'year' => '2023']); + GniEntry::create(['country_id' => 'CHN', 'currency_id' => 'CNY', 'gni' => 88699.8036449731, 'year' => '2023']); + GniEntry::create(['country_id' => 'COL', 'currency_id' => 'COP', 'gni' => 30010723.0751587, 'year' => '2023']); + GniEntry::create(['country_id' => 'COM', 'currency_id' => 'KMF', 'gni' => 723651.66329255, 'year' => '2023']); + GniEntry::create(['country_id' => 'COD', 'currency_id' => 'CDF', 'gni' => 1536564.79971413, 'year' => '2023']); + GniEntry::create(['country_id' => 'COG', 'currency_id' => 'XAF', 'gni' => 1438809.02100569, 'year' => '2023']); + GniEntry::create(['country_id' => 'CRI', 'currency_id' => 'CRC', 'gni' => 8333244.98837625, 'year' => '2023']); + GniEntry::create(['country_id' => 'CIV', 'currency_id' => 'XOF', 'gni' => 1588346.33126882, 'year' => '2023']); + GniEntry::create(['country_id' => 'HRV', 'currency_id' => 'EUR', 'gni' => 19863.8804629918, 'year' => '2023']); + GniEntry::create(['country_id' => 'CUB', 'currency_id' => 'CUP', 'gni' => 9002.07896349969, 'year' => '2019']); + GniEntry::create(['country_id' => 'CUW', 'currency_id' => 'ANG', 'gni' => 36611.6698832569, 'year' => '2022']); + GniEntry::create(['country_id' => 'CYP', 'currency_id' => 'EUR', 'gni' => 28851.66015625, 'year' => '2023']); + GniEntry::create(['country_id' => 'CZE', 'currency_id' => 'CZK', 'gni' => 644775.361576305, 'year' => '2023']); + GniEntry::create(['country_id' => 'DNK', 'currency_id' => 'DKK', 'gni' => 484759.419227873, 'year' => '2023']); + GniEntry::create(['country_id' => 'DJI', 'currency_id' => 'DJF', 'gni' => 626548.881741908, 'year' => '2023']); + GniEntry::create(['country_id' => 'DMA', 'currency_id' => 'XCD', 'gni' => 24241.9222343921, 'year' => '2023']); + GniEntry::create(['country_id' => 'DOM', 'currency_id' => 'DOP', 'gni' => 574840.976774293, 'year' => '2023']); + GniEntry::create(['country_id' => 'ECU', 'currency_id' => 'USD', 'gni' => 6386.64237850955, 'year' => '2023']); + GniEntry::create(['country_id' => 'EGY', 'currency_id' => 'EGP', 'gni' => 86155.7903086173, 'year' => '2023']); + GniEntry::create(['country_id' => 'SLV', 'currency_id' => 'USD', 'gni' => 5007.74162470897, 'year' => '2023']); + GniEntry::create(['country_id' => 'GNQ', 'currency_id' => 'XAF', 'gni' => 3071268.85834641, 'year' => '2023']); + GniEntry::create(['country_id' => 'EST', 'currency_id' => 'EUR', 'gni' => 26656.4201130082, 'year' => '2023']); + GniEntry::create(['country_id' => 'SWZ', 'currency_id' => 'SZL', 'gni' => 65372.5800324077, 'year' => '2023']); + GniEntry::create(['country_id' => 'ETH', 'currency_id' => 'ETB', 'gni' => 68762.1999594395, 'year' => '2023']); + GniEntry::create(['country_id' => 'FRO', 'currency_id' => 'DKK', 'gni' => 487402.524015822, 'year' => '2022']); + GniEntry::create(['country_id' => 'FJI', 'currency_id' => 'FJD', 'gni' => 12287.2296204606, 'year' => '2023']); + GniEntry::create(['country_id' => 'FIN', 'currency_id' => 'EUR', 'gni' => 49627.1308090019, 'year' => '2023']); + GniEntry::create(['country_id' => 'FRA', 'currency_id' => 'EUR', 'gni' => 41770.1474606908, 'year' => '2023']); + GniEntry::create(['country_id' => 'GAB', 'currency_id' => 'XAF', 'gni' => 4585875.86265211, 'year' => '2023']); + GniEntry::create(['country_id' => 'GMB', 'currency_id' => 'GMD', 'gni' => 50879.890428564, 'year' => '2023']); + GniEntry::create(['country_id' => 'GEO', 'currency_id' => 'GMD', 'gni' => 19921.2054148999, 'year' => '2023']); + GniEntry::create(['country_id' => 'DEU', 'currency_id' => 'EUR', 'gni' => 50734.4221716967, 'year' => '2023']); + GniEntry::create(['country_id' => 'GHA', 'currency_id' => 'GHS', 'gni' => 24358.5850467789, 'year' => '2023']); + GniEntry::create(['country_id' => 'GRC', 'currency_id' => 'EUR', 'gni' => 21105.4784899134, 'year' => '2023']); + GniEntry::create(['country_id' => 'GRD', 'currency_id' => 'XCD', 'gni' => 26477.9917745673, 'year' => '2023']); + GniEntry::create(['country_id' => 'GTM', 'currency_id' => 'GTQ', 'gni' => 44603.2290142197, 'year' => '2023']); + GniEntry::create(['country_id' => 'GIN', 'currency_id' => 'GNF', 'gni' => 13167960.8337822, 'year' => '2023']); + GniEntry::create(['country_id' => 'GNB', 'currency_id' => 'XOF', 'gni' => 562220.825026464, 'year' => '2023']); + GniEntry::create(['country_id' => 'GUY', 'currency_id' => 'GYD', 'gni' => 3895774.81402841, 'year' => '2023']); + GniEntry::create(['country_id' => 'HTI', 'currency_id' => 'HTG', 'gni' => 238719.689982555, 'year' => '2023']); + GniEntry::create(['country_id' => 'HND', 'currency_id' => 'HNL', 'gni' => 74017.3071074227, 'year' => '2023']); + GniEntry::create(['country_id' => 'HKG', 'currency_id' => 'HKD', 'gni' => 432452.064064967, 'year' => '2023']); + GniEntry::create(['country_id' => 'HUN', 'currency_id' => 'HUF', 'gni' => 7599712.49371581, 'year' => '2023']); + GniEntry::create(['country_id' => 'ISL', 'currency_id' => 'ISK', 'gni' => 11112372.9674797, 'year' => '2023']); + GniEntry::create(['country_id' => 'IND', 'currency_id' => 'INR', 'gni' => 202700.632826738, 'year' => '2023']); + GniEntry::create(['country_id' => 'IDN', 'currency_id' => 'IDR', 'gni' => 73340320.8927802, 'year' => '2023']); + GniEntry::create(['country_id' => 'IRN', 'currency_id' => 'IRR', 'gni' => 1630423154.29808, 'year' => '2023']); + GniEntry::create(['country_id' => 'IRQ', 'currency_id' => 'IQD', 'gni' => 7289296.05131881, 'year' => '2023']); + GniEntry::create(['country_id' => 'IRL', 'currency_id' => 'EUR', 'gni' => 74123.6003011564, 'year' => '2023']); + GniEntry::create(['country_id' => 'IMN', 'currency_id' => 'GBP', 'gni' => 58918.4458184494, 'year' => '2023']); + GniEntry::create(['country_id' => 'ISR', 'currency_id' => 'ILS', 'gni' => 191316.505888261, 'year' => '2023']); + GniEntry::create(['country_id' => 'ITA', 'currency_id' => 'EUR', 'gni' => 35426.965634741, 'year' => '2023']); + GniEntry::create(['country_id' => 'JAM', 'currency_id' => 'JMD', 'gni' => 1030844.66247915, 'year' => '2023']); + GniEntry::create(['country_id' => 'JPN', 'currency_id' => 'JPY', 'gni' => 4983588.07958457, 'year' => '2023']); + GniEntry::create(['country_id' => 'JOR', 'currency_id' => 'JOD', 'gni' => 3153.35821583592, 'year' => '2023']); + GniEntry::create(['country_id' => 'KAZ', 'currency_id' => 'KZT', 'gni' => 5396427.59280985, 'year' => '2023']); + GniEntry::create(['country_id' => 'KEN', 'currency_id' => 'KES', 'gni' => 268203.849247667, 'year' => '2023']); + GniEntry::create(['country_id' => 'KIR', 'currency_id' => 'AUD', 'gni' => 5270.38638491329, 'year' => '2023']); + GniEntry::create(['country_id' => 'KOR', 'currency_id' => 'KRW', 'gni' => 44051004.2626153, 'year' => '2023']); + GniEntry::create(['country_id' => 'XKX', 'currency_id' => 'EUR', 'gni' => 5599.81740528937, 'year' => '2023']); + GniEntry::create(['country_id' => 'KWT', 'currency_id' => 'KWD', 'gni' => 13849.6200156636, 'year' => '2023']); + GniEntry::create(['country_id' => 'KGZ', 'currency_id' => 'SOM', 'gni' => 164503.746329063, 'year' => '2023']); + GniEntry::create(['country_id' => 'LAO', 'currency_id' => 'LAK', 'gni' => 34029460.6963733, 'year' => '2023']); + GniEntry::create(['country_id' => 'LVA', 'currency_id' => 'EUR', 'gni' => 20895.2186944321, 'year' => '2023']); + GniEntry::create(['country_id' => 'LBN', 'currency_id' => 'LBP', 'gni' => 101442744.944705, 'year' => '2022']); + GniEntry::create(['country_id' => 'LSO', 'currency_id' => 'LSL', 'gni' => 18953.9587051513, 'year' => '2023']); + GniEntry::create(['country_id' => 'LBR', 'currency_id' => 'LRD', 'gni' => 748.932752372159, 'year' => '2023']); + GniEntry::create(['country_id' => 'LBY', 'currency_id' => 'LYD', 'gni' => 35327.4528244705, 'year' => '2023']); + GniEntry::create(['country_id' => 'LIE', 'currency_id' => 'CHF', 'gni' => 166172.289249212, 'year' => '2022']); + GniEntry::create(['country_id' => 'LTU', 'currency_id' => 'EUR', 'gni' => 24205.2507251937, 'year' => '2023']); + GniEntry::create(['country_id' => 'LUX', 'currency_id' => 'EUR', 'gni' => 81503.118182898, 'year' => '2023']); + GniEntry::create(['country_id' => 'MAC', 'currency_id' => 'MOP', 'gni' => 339026.393619959, 'year' => '2022']); + GniEntry::create(['country_id' => 'MDG', 'currency_id' => 'MGA', 'gni' => 2293689.81642059, 'year' => '2023']); + GniEntry::create(['country_id' => 'MWI', 'currency_id' => 'MWK', 'gni' => 761396.311278497, 'year' => '2023']); + GniEntry::create(['country_id' => 'MYS', 'currency_id' => 'MYR', 'gni' => 51520.6621969321, 'year' => '2023']); + GniEntry::create(['country_id' => 'MDV', 'currency_id' => 'MVR', 'gni' => 170613.684340974, 'year' => '2023']); + GniEntry::create(['country_id' => 'MLI', 'currency_id' => 'XOF', 'gni' => 519251.088530469, 'year' => '2023']); + GniEntry::create(['country_id' => 'MLT', 'currency_id' => 'EUR', 'gni' => 31911.1776337056, 'year' => '2023']); + GniEntry::create(['country_id' => 'MHL', 'currency_id' => 'USD', 'gni' => 7734.37593681924, 'year' => '2023']); + GniEntry::create(['country_id' => 'MRT', 'currency_id' => 'MRU', 'gni' => 78598.5041453131, 'year' => '2023']); + GniEntry::create(['country_id' => 'MUS', 'currency_id' => 'MUR', 'gni' => 529574.375456468, 'year' => '2023']); + GniEntry::create(['country_id' => 'MEX', 'currency_id' => 'MXN', 'gni' => 241202.752708762, 'year' => '2023']); + GniEntry::create(['country_id' => 'FSM', 'currency_id' => 'USD', 'gni' => 4376.34941505242, 'year' => '2023']); + GniEntry::create(['country_id' => 'MDA', 'currency_id' => 'MDL', 'gni' => 122334.382882588, 'year' => '2023']); + GniEntry::create(['country_id' => 'MNG', 'currency_id' => 'MNT', 'gni' => 18079704.6116553, 'year' => '2023']); + GniEntry::create(['country_id' => 'MNE', 'currency_id' => 'EUR', 'gni' => 11221.58129888, 'year' => '2023']); + GniEntry::create(['country_id' => 'MAR', 'currency_id' => 'MAD', 'gni' => 36650.11328125, 'year' => '2023']); + GniEntry::create(['country_id' => 'MOZ', 'currency_id' => 'MZN', 'gni' => 35408.3165601321, 'year' => '2023']); + GniEntry::create(['country_id' => 'MMR', 'currency_id' => 'MMK', 'gni' => 2449586.51422495, 'year' => '2023']); + GniEntry::create(['country_id' => 'NAM', 'currency_id' => 'NAD', 'gni' => 83453.655239258, 'year' => '2023']); + GniEntry::create(['country_id' => 'NRU', 'currency_id' => 'AUD', 'gni' => 30506.4449089703, 'year' => '2023']); + GniEntry::create(['country_id' => 'NPL', 'currency_id' => 'NPR', 'gni' => 175129.20100011, 'year' => '2023']); + GniEntry::create(['country_id' => 'NLD', 'currency_id' => 'EUR', 'gni' => 57491.260179999, 'year' => '2023']); + GniEntry::create(['country_id' => 'NCL', 'currency_id' => 'XPF', 'gni' => 3898812.82591812, 'year' => '2021']); + GniEntry::create(['country_id' => 'NZL', 'currency_id' => 'NZD', 'gni' => 77038.2760602292, 'year' => '2023']); + GniEntry::create(['country_id' => 'NIC', 'currency_id' => 'NIO', 'gni' => 87582.3365562968, 'year' => '2023']); + GniEntry::create(['country_id' => 'NER', 'currency_id' => 'XOF', 'gni' => 360834.847894356, 'year' => '2023']); + GniEntry::create(['country_id' => 'NGA', 'currency_id' => 'NGN', 'gni' => 1027299.30745738, 'year' => '2023']); + GniEntry::create(['country_id' => 'MKD', 'currency_id' => 'MKD', 'gni' => 438486.857636398, 'year' => '2023']); + GniEntry::create(['country_id' => 'NOR', 'currency_id' => 'NOK', 'gni' => 967726.912337121, 'year' => '2023']); + GniEntry::create(['country_id' => 'OMN', 'currency_id' => 'OMR', 'gni' => 8324.43009281707, 'year' => '2023']); + GniEntry::create(['country_id' => 'PAK', 'currency_id' => 'PKR', 'gni' => 343623.076207886, 'year' => '2023']); + GniEntry::create(['country_id' => 'PLW', 'currency_id' => 'USD', 'gni' => 14938.7479013847, 'year' => '2023']); + GniEntry::create(['country_id' => 'PAN', 'currency_id' => 'PAB', 'gni' => 17917.5747275982, 'year' => '2023']); + GniEntry::create(['country_id' => 'PNG', 'currency_id' => 'PGK', 'gni' => 10142.9525521516, 'year' => '2023']); + GniEntry::create(['country_id' => 'PRY', 'currency_id' => 'PYG', 'gni' => 44174960.3935371, 'year' => '2023']); + GniEntry::create(['country_id' => 'PER', 'currency_id' => 'PEN', 'gni' => 27671.6669792572, 'year' => '2023']); + GniEntry::create(['country_id' => 'PHL', 'currency_id' => 'PHP', 'gni' => 230014.744175104, 'year' => '2023']); + GniEntry::create(['country_id' => 'POL', 'currency_id' => 'PLN', 'gni' => 89045.1519876234, 'year' => '2023']); + GniEntry::create(['country_id' => 'PRT', 'currency_id' => 'EUR', 'gni' => 24754.9158236778, 'year' => '2023']); + GniEntry::create(['country_id' => 'PRI', 'currency_id' => 'USD', 'gni' => 25439.3514533996, 'year' => '2023']); + GniEntry::create(['country_id' => 'QAT', 'currency_id' => 'QAR', 'gni' => 307234.058270845, 'year' => '2022']); + GniEntry::create(['country_id' => 'ROU', 'currency_id' => 'RON', 'gni' => 81993.7469156884, 'year' => '2023']); + GniEntry::create(['country_id' => 'RUS', 'currency_id' => 'RUB', 'gni' => 1160969.5, 'year' => '2023']); + GniEntry::create(['country_id' => 'RWA', 'currency_id' => 'RWF', 'gni' => 1137294.32581066, 'year' => '2023']); + GniEntry::create(['country_id' => 'WSM', 'currency_id' => 'WST', 'gni' => 11159.6908911251, 'year' => '2023']); + GniEntry::create(['country_id' => 'SMR', 'currency_id' => 'EUR', 'gni' => 41750.7715335605, 'year' => '2021']); + GniEntry::create(['country_id' => 'STP', 'currency_id' => 'STN', 'gni' => 60136.4972224139, 'year' => '2023']); + GniEntry::create(['country_id' => 'SAU', 'currency_id' => 'SAR', 'gni' => 108948.393003226, 'year' => '2023']); + GniEntry::create(['country_id' => 'SEN', 'currency_id' => 'XOF', 'gni' => 1023778.59168438, 'year' => '2023']); + GniEntry::create(['country_id' => 'SRB', 'currency_id' => 'RSD', 'gni' => 1163166.83582083, 'year' => '2023']); + GniEntry::create(['country_id' => 'SYC', 'currency_id' => 'SCR', 'gni' => 248667.566145959, 'year' => '2023']); + GniEntry::create(['country_id' => 'SLE', 'currency_id' => 'SLE', 'gni' => 10651.8052592329, 'year' => '2023']); + GniEntry::create(['country_id' => 'SGP', 'currency_id' => 'SGD', 'gni' => 95454.91722387, 'year' => '2023']); + GniEntry::create(['country_id' => 'SXM', 'currency_id' => 'ANG', 'gni' => 65687.9961345627, 'year' => '2022']); + GniEntry::create(['country_id' => 'SVK', 'currency_id' => 'EUR', 'gni' => 22046.4776274522, 'year' => '2023']); + GniEntry::create(['country_id' => 'SVN', 'currency_id' => 'EUR', 'gni' => 29301.0900080555, 'year' => '2023']); + GniEntry::create(['country_id' => 'SLB', 'currency_id' => 'SBD', 'gni' => 18737.2582466263, 'year' => '2023']); + GniEntry::create(['country_id' => 'SOM', 'currency_id' => 'SOS', 'gni' => 17444691.3268301, 'year' => '2023']); + GniEntry::create(['country_id' => 'ZAF', 'currency_id' => 'ZAR', 'gni' => 113797.768513997, 'year' => '2023']); + GniEntry::create(['country_id' => 'ESP', 'currency_id' => 'EUR', 'gni' => 30013.7815696517, 'year' => '2023']); + GniEntry::create(['country_id' => 'LKA', 'currency_id' => 'LKR', 'gni' => 1213158.55152698, 'year' => '2023']); + GniEntry::create(['country_id' => 'KNA', 'currency_id' => 'XCD', 'gni' => 59322.1526541723, 'year' => '2023']); + GniEntry::create(['country_id' => 'LCA', 'currency_id' => 'XCD', 'gni' => 34519.753199794, 'year' => '2023']); + GniEntry::create(['country_id' => 'VCT', 'currency_id' => 'XCD', 'gni' => 27561.7658971243, 'year' => '2023']); + GniEntry::create(['country_id' => 'SDN', 'currency_id' => 'SDG', 'gni' => 1600182.5, 'year' => '2023']); + GniEntry::create(['country_id' => 'SUR', 'currency_id' => 'SRD', 'gni' => 205025.957866806, 'year' => '2023']); + GniEntry::create(['country_id' => 'SWE', 'currency_id' => 'SEK', 'gni' => 621109.288053336, 'year' => '2023']); + GniEntry::create(['country_id' => 'CHE', 'currency_id' => 'CHF', 'gni' => 87037.4817520035, 'year' => '2023']); + GniEntry::create(['country_id' => 'SYR', 'currency_id' => 'SYP', 'gni' => 1160320.49157661, 'year' => '2021']); + GniEntry::create(['country_id' => 'TJK', 'currency_id' => 'TJS', 'gni' => 16190.2780419031, 'year' => '2023']); + GniEntry::create(['country_id' => 'TZA', 'currency_id' => 'TZS', 'gni' => 2834965.5, 'year' => '2023']); + GniEntry::create(['country_id' => 'THA', 'currency_id' => 'THB', 'gni' => 243766.465497084, 'year' => '2023']); + GniEntry::create(['country_id' => 'TLS', 'currency_id' => 'USD', 'gni' => 1897.17966408784, 'year' => '2023']); + GniEntry::create(['country_id' => 'TGO', 'currency_id' => 'XOF', 'gni' => 617079.084702455, 'year' => '2023']); + GniEntry::create(['country_id' => 'TON', 'currency_id' => 'TOP', 'gni' => 11461.9214284377, 'year' => '2022']); + GniEntry::create(['country_id' => 'TTO', 'currency_id' => 'TTD', 'gni' => 119152.268756307, 'year' => '2023']); + GniEntry::create(['country_id' => 'TUN', 'currency_id' => 'TND', 'gni' => 11775.9045921751, 'year' => '2023']); + GniEntry::create(['country_id' => 'TUR', 'currency_id' => 'TRY', 'gni' => 304835.519807562, 'year' => '2023']); + GniEntry::create(['country_id' => 'TKM', 'currency_id' => 'TMT', 'gni' => 31895.8511016002, 'year' => '2023']); + GniEntry::create(['country_id' => 'TCA', 'currency_id' => 'USD', 'gni' => 29144.5093775203, 'year' => '2023']); + GniEntry::create(['country_id' => 'TUV', 'currency_id' => 'AUD', 'gni' => 11123.4888336548, 'year' => '2023']); + GniEntry::create(['country_id' => 'UGA', 'currency_id' => 'UGX', 'gni' => 3730683.89696551, 'year' => '2023']); + GniEntry::create(['country_id' => 'UKR', 'currency_id' => 'UAH', 'gni' => 195344.4375, 'year' => '2023']); + GniEntry::create(['country_id' => 'ARE', 'currency_id' => 'AED', 'gni' => 194202.454365221, 'year' => '2023']); + GniEntry::create(['country_id' => 'GBR', 'currency_id' => 'GBP', 'gni' => 38804.9890270666, 'year' => '2023']); + GniEntry::create(['country_id' => 'USA', 'currency_id' => 'USD', 'gni' => 82185.3563724002, 'year' => '2023']); + GniEntry::create(['country_id' => 'URY', 'currency_id' => 'UYU', 'gni' => 814919.874390595, 'year' => '2023']); + GniEntry::create(['country_id' => 'UZB', 'currency_id' => 'UZS', 'gni' => 29046144.3285177, 'year' => '2023']); + GniEntry::create(['country_id' => 'VUT', 'currency_id' => 'VUV', 'gni' => 456148.793274823, 'year' => '2023']); + GniEntry::create(['country_id' => 'VNM', 'currency_id' => 'VND', 'gni' => 97992949.9926357, 'year' => '2023']); + GniEntry::create(['country_id' => 'PSE', 'currency_id' => 'ILS', 'gni' => 4037.79065378511, 'year' => '2023']); + GniEntry::create(['country_id' => 'ZMB', 'currency_id' => 'ZMW', 'gni' => 26550.1595863865, 'year' => '2023']); + GniEntry::create(['country_id' => 'ZWE', 'currency_id' => 'ZWL', 'gni' => 7394702.8915882, 'year' => '2023']); + } +} diff --git a/database/seeders/Prep/LanguageStringTypeSeeder.php b/database/seeders/Prep/LanguageStringTypeSeeder.php index 29581fa8..55b23108 100644 --- a/database/seeders/Prep/LanguageStringTypeSeeder.php +++ b/database/seeders/Prep/LanguageStringTypeSeeder.php @@ -15,6 +15,7 @@ public function run(): void $languageStringTypes = [ ['name' => 'label'], ['name' => 'hint'], + ['name' => 'relevant_message'], ['name' => 'required_message'], ['name' => 'constraint_message'], ['name' => 'guidance_hint'], diff --git a/database/seeders/Prep/LocaleSeeder.php b/database/seeders/Prep/LocaleSeeder.php new file mode 100644 index 00000000..7f9a3d31 --- /dev/null +++ b/database/seeders/Prep/LocaleSeeder.php @@ -0,0 +1,24 @@ +locales() + ->create([]); + + + } +} diff --git a/database/seeders/Test/CreateTestDatasets.php b/database/seeders/Test/CreateTestDatasets.php new file mode 100644 index 00000000..eab1da46 --- /dev/null +++ b/database/seeders/Test/CreateTestDatasets.php @@ -0,0 +1,52 @@ + 'Animals'], + ['entity_model' => Animal::class, 'lookup_table' => true, 'primary_key' => 'id'] + ); + Dataset::updateOrCreate( + ['name' => 'Animal Products'], + ['entity_model' => AnimalProduct::class, 'lookup_table' => true, 'primary_key' => 'id'] + ); + Dataset::updateOrCreate( + ['name' => 'Crops'], + ['entity_model' => Crop::class, 'lookup_table' => true, 'primary_key' => 'id'] + ); + Dataset::updateOrCreate( + ['name' => 'Crop Products'], + ['entity_model' => CropProduct::class, 'lookup_table' => true, 'primary_key' => 'id'] + ); + Dataset::updateOrCreate( + ['name' => 'Enumerators'], + ['entity_model' => Animal::class, 'lookup_table' => true, 'primary_key' => 'id'] + ); + Dataset::updateOrCreate( + ['name' => 'Units'], + ['entity_model' => Unit::class, 'lookup_table' => true, 'primary_key' => 'id'] + ); + Dataset::updateOrCreate( + ['name' => 'Enumerators'], + ['entity_model' => Enumerator::class, 'lookup_table' => true, 'primary_key' => 'id'] + ); + } +} diff --git a/database/seeders/Un49LocationSeeder.php b/database/seeders/Un49LocationSeeder.php new file mode 100644 index 00000000..3ddfbcbe --- /dev/null +++ b/database/seeders/Un49LocationSeeder.php @@ -0,0 +1,307 @@ +truncate(); + DB::table('regions')->truncate(); + DB::table('countries')->truncate(); + + Continent::create(['id' => '002', 'name' => 'Africa']); + Continent::create(['id' => '019', 'name' => 'Americas']); + Continent::create(['id' => '142', 'name' => 'Asia']); + Continent::create(['id' => '150', 'name' => 'Europe']); + Continent::create(['id' => '009', 'name' => 'Oceania']); + + Region::create(['continent_id' => '002', 'id' => '015', 'name' => 'Northern Africa']); + + Region::create(['continent_id' => '002', 'id' => '202', 'name' => 'Sub-Saharan Africa']); + Region::create(['continent_id' => '002', 'id' => '014', 'parent_id' => '202', 'name' => 'Eastern Africa']); + Region::create(['continent_id' => '002', 'id' => '017', 'parent_id' => '202', 'name' => 'Middle Africa']); + Region::create(['continent_id' => '002', 'id' => '018', 'parent_id' => '202', 'name' => 'Southern Africa']); + Region::create(['continent_id' => '002', 'id' => '011', 'parent_id' => '202', 'name' => 'Western Africa']); + + Region::create(['continent_id' => '019', 'id' => '419', 'name' => 'Latin America and the Caribbean']); + Region::create(['continent_id' => '019', 'id' => '029', 'parent_id' => '419', 'name' => 'Caribbean']); + Region::create(['continent_id' => '019', 'id' => '013', 'parent_id' => '419', 'name' => 'Central America']); + Region::create(['continent_id' => '019', 'id' => '005', 'parent_id' => '419', 'name' => 'South America']); + + Region::create(['continent_id' => '019', 'id' => '021', 'name' => 'Northern America']); + Region::create(['continent_id' => '142', 'id' => '143', 'name' => 'Central Asia']); + Region::create(['continent_id' => '142', 'id' => '030', 'name' => 'Eastern Asia']); + Region::create(['continent_id' => '142', 'id' => '035', 'name' => 'South-eastern Asia']); + Region::create(['continent_id' => '142', 'id' => '034', 'name' => 'Southern Asia']); + Region::create(['continent_id' => '142', 'id' => '145', 'name' => 'Western Asia']); + Region::create(['continent_id' => '150', 'id' => '151', 'name' => 'Eastern Europe']); + Region::create(['continent_id' => '150', 'id' => '154', 'name' => 'Northern Europe']); + Region::create(['continent_id' => '150', 'id' => '830', 'name' => 'Channel Islands']); + Region::create(['continent_id' => '150', 'id' => '039', 'name' => 'Southern Europe']); + Region::create(['continent_id' => '150', 'id' => '155', 'name' => 'Western Europe']); + Region::create(['continent_id' => '009', 'id' => '053', 'name' => 'Australia and New Zealand']); + Region::create(['continent_id' => '009', 'id' => '054', 'name' => 'Melanesia']); + Region::create(['continent_id' => '009', 'id' => '057', 'name' => 'Micronesia']); + Region::create(['continent_id' => '009', 'id' => '061', 'name' => 'Polynesia']); + + Country::create(['region_id' => '015', 'name' => 'Algeria', 'id' => '012', 'iso_alpha2' => 'DZ', 'iso_alpha3' => 'DZA']); + Country::create(['region_id' => '015', 'name' => 'Egypt', 'id' => '818', 'iso_alpha2' => 'EG', 'iso_alpha3' => 'EGY']); + Country::create(['region_id' => '015', 'name' => 'Libya', 'id' => '434', 'iso_alpha2' => 'LY', 'iso_alpha3' => 'LBY']); + Country::create(['region_id' => '015', 'name' => 'Morocco', 'id' => '504', 'iso_alpha2' => 'MA', 'iso_alpha3' => 'MAR']); + Country::create(['region_id' => '015', 'name' => 'Sudan', 'id' => '729', 'iso_alpha2' => 'SD', 'iso_alpha3' => 'SDN']); + Country::create(['region_id' => '015', 'name' => 'Tunisia', 'id' => '788', 'iso_alpha2' => 'TN', 'iso_alpha3' => 'TUN']); + Country::create(['region_id' => '015', 'name' => 'Western Sahara', 'id' => '732', 'iso_alpha2' => 'EH', 'iso_alpha3' => 'ESH']); + Country::create(['region_id' => '014', 'name' => 'British Indian Ocean Territory', 'id' => '086', 'iso_alpha2' => 'IO', 'iso_alpha3' => 'IOT']); + Country::create(['region_id' => '014', 'name' => 'Burundi', 'id' => '108', 'iso_alpha2' => 'BI', 'iso_alpha3' => 'BDI']); + Country::create(['region_id' => '014', 'name' => 'Comoros', 'id' => '174', 'iso_alpha2' => 'KM', 'iso_alpha3' => 'COM']); + Country::create(['region_id' => '014', 'name' => 'Djibouti', 'id' => '262', 'iso_alpha2' => 'DJ', 'iso_alpha3' => 'DJI']); + Country::create(['region_id' => '014', 'name' => 'Eritrea', 'id' => '232', 'iso_alpha2' => 'ER', 'iso_alpha3' => 'ERI']); + Country::create(['region_id' => '014', 'name' => 'Ethiopia', 'id' => '231', 'iso_alpha2' => 'ET', 'iso_alpha3' => 'ETH']); + Country::create(['region_id' => '014', 'name' => 'French Southern Territories', 'id' => '260', 'iso_alpha2' => 'TF', 'iso_alpha3' => 'ATF']); + Country::create(['region_id' => '014', 'name' => 'Kenya', 'id' => '404', 'iso_alpha2' => 'KE', 'iso_alpha3' => 'KEN']); + Country::create(['region_id' => '014', 'name' => 'Madagascar', 'id' => '450', 'iso_alpha2' => 'MG', 'iso_alpha3' => 'MDG']); + Country::create(['region_id' => '014', 'name' => 'Malawi', 'id' => '454', 'iso_alpha2' => 'MW', 'iso_alpha3' => 'MWI']); + Country::create(['region_id' => '014', 'name' => 'Mauritius', 'id' => '480', 'iso_alpha2' => 'MU', 'iso_alpha3' => 'MUS']); + Country::create(['region_id' => '014', 'name' => 'Mayotte', 'id' => '175', 'iso_alpha2' => 'YT', 'iso_alpha3' => 'MYT']); + Country::create(['region_id' => '014', 'name' => 'Mozambique', 'id' => '508', 'iso_alpha2' => 'MZ', 'iso_alpha3' => 'MOZ']); + Country::create(['region_id' => '014', 'name' => 'Réunion', 'id' => '638', 'iso_alpha2' => 'RE', 'iso_alpha3' => 'REU']); + Country::create(['region_id' => '014', 'name' => 'Rwanda', 'id' => '646', 'iso_alpha2' => 'RW', 'iso_alpha3' => 'RWA']); + Country::create(['region_id' => '014', 'name' => 'Seychelles', 'id' => '690', 'iso_alpha2' => 'SC', 'iso_alpha3' => 'SYC']); + Country::create(['region_id' => '014', 'name' => 'Somalia', 'id' => '706', 'iso_alpha2' => 'SO', 'iso_alpha3' => 'SOM']); + Country::create(['region_id' => '014', 'name' => 'South Sudan', 'id' => '728', 'iso_alpha2' => 'SS', 'iso_alpha3' => 'SSD']); + Country::create(['region_id' => '014', 'name' => 'Uganda', 'id' => '800', 'iso_alpha2' => 'UG', 'iso_alpha3' => 'UGA']); + Country::create(['region_id' => '014', 'name' => 'United Republic of Tanzania', 'id' => '834', 'iso_alpha2' => 'TZ', 'iso_alpha3' => 'TZA']); + Country::create(['region_id' => '014', 'name' => 'Zambia', 'id' => '894', 'iso_alpha2' => 'ZM', 'iso_alpha3' => 'ZMB']); + Country::create(['region_id' => '014', 'name' => 'Zimbabwe', 'id' => '716', 'iso_alpha2' => 'ZW', 'iso_alpha3' => 'ZWE']); + Country::create(['region_id' => '017', 'name' => 'Angola', 'id' => '024', 'iso_alpha2' => 'AO', 'iso_alpha3' => 'AGO']); + Country::create(['region_id' => '017', 'name' => 'Cameroon', 'id' => '120', 'iso_alpha2' => 'CM', 'iso_alpha3' => 'CMR']); + Country::create(['region_id' => '017', 'name' => 'Central African Republic', 'id' => '140', 'iso_alpha2' => 'CF', 'iso_alpha3' => 'CAF']); + Country::create(['region_id' => '017', 'name' => 'Chad', 'id' => '148', 'iso_alpha2' => 'TD', 'iso_alpha3' => 'TCD']); + Country::create(['region_id' => '017', 'name' => 'Congo', 'id' => '178', 'iso_alpha2' => 'CG', 'iso_alpha3' => 'COG']); + Country::create(['region_id' => '017', 'name' => 'Democratic Republic of the Congo', 'id' => '180', 'iso_alpha2' => 'CD', 'iso_alpha3' => 'COD']); + Country::create(['region_id' => '017', 'name' => 'Equatorial Guinea', 'id' => '226', 'iso_alpha2' => 'GQ', 'iso_alpha3' => 'GNQ']); + Country::create(['region_id' => '017', 'name' => 'Gabon', 'id' => '266', 'iso_alpha2' => 'GA', 'iso_alpha3' => 'GAB']); + Country::create(['region_id' => '017', 'name' => 'Sao Tome and Principe', 'id' => '678', 'iso_alpha2' => 'ST', 'iso_alpha3' => 'STP']); + Country::create(['region_id' => '018', 'name' => 'Botswana', 'id' => '072', 'iso_alpha2' => 'BW', 'iso_alpha3' => 'BWA']); + Country::create(['region_id' => '018', 'name' => 'Eswatini', 'id' => '748', 'iso_alpha2' => 'SZ', 'iso_alpha3' => 'SWZ']); + Country::create(['region_id' => '018', 'name' => 'Lesotho', 'id' => '426', 'iso_alpha2' => 'LS', 'iso_alpha3' => 'LSO']); + Country::create(['region_id' => '018', 'name' => 'Namibia', 'id' => '516', 'iso_alpha2' => 'NA', 'iso_alpha3' => 'NAM']); + Country::create(['region_id' => '018', 'name' => 'South Africa', 'id' => '710', 'iso_alpha2' => 'ZA', 'iso_alpha3' => 'ZAF']); + Country::create(['region_id' => '011', 'name' => 'Benin', 'id' => '204', 'iso_alpha2' => 'BJ', 'iso_alpha3' => 'BEN']); + Country::create(['region_id' => '011', 'name' => 'Burkina Faso', 'id' => '854', 'iso_alpha2' => 'BF', 'iso_alpha3' => 'BFA']); + Country::create(['region_id' => '011', 'name' => 'Cabo Verde', 'id' => '132', 'iso_alpha2' => 'CV', 'iso_alpha3' => 'CPV']); + Country::create(['region_id' => '011', 'name' => 'Côte d’Ivoire', 'id' => '384', 'iso_alpha2' => 'CI', 'iso_alpha3' => 'CIV']); + Country::create(['region_id' => '011', 'name' => 'Gambia', 'id' => '270', 'iso_alpha2' => 'GM', 'iso_alpha3' => 'GMB']); + Country::create(['region_id' => '011', 'name' => 'Ghana', 'id' => '288', 'iso_alpha2' => 'GH', 'iso_alpha3' => 'GHA']); + Country::create(['region_id' => '011', 'name' => 'Guinea', 'id' => '324', 'iso_alpha2' => 'GN', 'iso_alpha3' => 'GIN']); + Country::create(['region_id' => '011', 'name' => 'Guinea-Bissau', 'id' => '624', 'iso_alpha2' => 'GW', 'iso_alpha3' => 'GNB']); + Country::create(['region_id' => '011', 'name' => 'Liberia', 'id' => '430', 'iso_alpha2' => 'LR', 'iso_alpha3' => 'LBR']); + Country::create(['region_id' => '011', 'name' => 'Mali', 'id' => '466', 'iso_alpha2' => 'ML', 'iso_alpha3' => 'MLI']); + Country::create(['region_id' => '011', 'name' => 'Mauritania', 'id' => '478', 'iso_alpha2' => 'MR', 'iso_alpha3' => 'MRT']); + Country::create(['region_id' => '011', 'name' => 'Niger', 'id' => '562', 'iso_alpha2' => 'NE', 'iso_alpha3' => 'NER']); + Country::create(['region_id' => '011', 'name' => 'Nigeria', 'id' => '566', 'iso_alpha2' => 'NG', 'iso_alpha3' => 'NGA']); + Country::create(['region_id' => '011', 'name' => 'Saint Helena', 'id' => '654', 'iso_alpha2' => 'SH', 'iso_alpha3' => 'SHN']); + Country::create(['region_id' => '011', 'name' => 'Senegal', 'id' => '686', 'iso_alpha2' => 'SN', 'iso_alpha3' => 'SEN']); + Country::create(['region_id' => '011', 'name' => 'Sierra Leone', 'id' => '694', 'iso_alpha2' => 'SL', 'iso_alpha3' => 'SLE']); + Country::create(['region_id' => '011', 'name' => 'Togo', 'id' => '768', 'iso_alpha2' => 'TG', 'iso_alpha3' => 'TGO']); + Country::create(['region_id' => '029', 'name' => 'Anguilla', 'id' => '660', 'iso_alpha2' => 'AI', 'iso_alpha3' => 'AIA']); + Country::create(['region_id' => '029', 'name' => 'Antigua and Barbuda', 'id' => '028', 'iso_alpha2' => 'AG', 'iso_alpha3' => 'ATG']); + Country::create(['region_id' => '029', 'name' => 'Aruba', 'id' => '533', 'iso_alpha2' => 'AW', 'iso_alpha3' => 'ABW']); + Country::create(['region_id' => '029', 'name' => 'Bahamas', 'id' => '044', 'iso_alpha2' => 'BS', 'iso_alpha3' => 'BHS']); + Country::create(['region_id' => '029', 'name' => 'Barbados', 'id' => '052', 'iso_alpha2' => 'BB', 'iso_alpha3' => 'BRB']); + Country::create(['region_id' => '029', 'name' => 'Bonaire, Sint Eustatius and Saba', 'id' => '535', 'iso_alpha2' => 'BQ', 'iso_alpha3' => 'BES']); + Country::create(['region_id' => '029', 'name' => 'British Virgin Islands', 'id' => '092', 'iso_alpha2' => 'VG', 'iso_alpha3' => 'VGB']); + Country::create(['region_id' => '029', 'name' => 'Cayman Islands', 'id' => '136', 'iso_alpha2' => 'KY', 'iso_alpha3' => 'CYM']); + Country::create(['region_id' => '029', 'name' => 'Cuba', 'id' => '192', 'iso_alpha2' => 'CU', 'iso_alpha3' => 'CUB']); + Country::create(['region_id' => '029', 'name' => 'Curaçao', 'id' => '531', 'iso_alpha2' => 'CW', 'iso_alpha3' => 'CUW']); + Country::create(['region_id' => '029', 'name' => 'Dominica', 'id' => '212', 'iso_alpha2' => 'DM', 'iso_alpha3' => 'DMA']); + Country::create(['region_id' => '029', 'name' => 'Dominican Republic', 'id' => '214', 'iso_alpha2' => 'do ', 'iso_alpha3' => 'DOM']); + Country::create(['region_id' => '029', 'name' => 'Grenada', 'id' => '308', 'iso_alpha2' => 'GD', 'iso_alpha3' => 'GRD']); + Country::create(['region_id' => '029', 'name' => 'Guadeloupe', 'id' => '312', 'iso_alpha2' => 'GP', 'iso_alpha3' => 'GLP']); + Country::create(['region_id' => '029', 'name' => 'Haiti', 'id' => '332', 'iso_alpha2' => 'HT', 'iso_alpha3' => 'HTI']); + Country::create(['region_id' => '029', 'name' => 'Jamaica', 'id' => '388', 'iso_alpha2' => 'JM', 'iso_alpha3' => 'JAM']); + Country::create(['region_id' => '029', 'name' => 'Martinique', 'id' => '474', 'iso_alpha2' => 'MQ', 'iso_alpha3' => 'MTQ']); + Country::create(['region_id' => '029', 'name' => 'Montserrat', 'id' => '500', 'iso_alpha2' => 'MS', 'iso_alpha3' => 'MSR']); + Country::create(['region_id' => '029', 'name' => 'Puerto Rico', 'id' => '630', 'iso_alpha2' => 'PR', 'iso_alpha3' => 'PRI']); + Country::create(['region_id' => '029', 'name' => 'Saint Barthélemy', 'id' => '652', 'iso_alpha2' => 'BL', 'iso_alpha3' => 'BLM']); + Country::create(['region_id' => '029', 'name' => 'Saint Kitts and Nevis', 'id' => '659', 'iso_alpha2' => 'KN', 'iso_alpha3' => 'KNA']); + Country::create(['region_id' => '029', 'name' => 'Saint Lucia', 'id' => '662', 'iso_alpha2' => 'LC', 'iso_alpha3' => 'LCA']); + Country::create(['region_id' => '029', 'name' => 'Saint Martin(French Part)', 'id' => '663', 'iso_alpha2' => 'MF', 'iso_alpha3' => 'MAF']); + Country::create(['region_id' => '029', 'name' => 'Saint Vincent and the Grenadines', 'id' => '670', 'iso_alpha2' => 'VC', 'iso_alpha3' => 'VCT']); + Country::create(['region_id' => '029', 'name' => 'Sint Maarten(Dutch part)', 'id' => '534', 'iso_alpha2' => 'SX', 'iso_alpha3' => 'SXM']); + Country::create(['region_id' => '029', 'name' => 'Trinidad and Tobago', 'id' => '780', 'iso_alpha2' => 'TT', 'iso_alpha3' => 'TTO']); + Country::create(['region_id' => '029', 'name' => 'Turks and Caicos Islands', 'id' => '796', 'iso_alpha2' => 'TC', 'iso_alpha3' => 'TCA']); + Country::create(['region_id' => '029', 'name' => 'United States Virgin Islands', 'id' => '850', 'iso_alpha2' => 'VI', 'iso_alpha3' => 'VIR']); + Country::create(['region_id' => '013', 'name' => 'Belize', 'id' => '084', 'iso_alpha2' => 'BZ', 'iso_alpha3' => 'BLZ']); + Country::create(['region_id' => '013', 'name' => 'Costa Rica', 'id' => '188', 'iso_alpha2' => 'CR', 'iso_alpha3' => 'CRI']); + Country::create(['region_id' => '013', 'name' => 'El Salvador', 'id' => '222', 'iso_alpha2' => 'SV', 'iso_alpha3' => 'SLV']); + Country::create(['region_id' => '013', 'name' => 'Guatemala', 'id' => '320', 'iso_alpha2' => 'GT', 'iso_alpha3' => 'GTM']); + Country::create(['region_id' => '013', 'name' => 'Honduras', 'id' => '340', 'iso_alpha2' => 'HN', 'iso_alpha3' => 'HND']); + Country::create(['region_id' => '013', 'name' => 'Mexico', 'id' => '484', 'iso_alpha2' => 'MX', 'iso_alpha3' => 'MEX']); + Country::create(['region_id' => '013', 'name' => 'Nicaragua', 'id' => '558', 'iso_alpha2' => 'NI', 'iso_alpha3' => 'NIC']); + Country::create(['region_id' => '013', 'name' => 'Panama', 'id' => '591', 'iso_alpha2' => 'PA', 'iso_alpha3' => 'PAN']); + Country::create(['region_id' => '005', 'name' => 'Argentina', 'id' => '032', 'iso_alpha2' => 'AR', 'iso_alpha3' => 'ARG']); + Country::create(['region_id' => '005', 'name' => 'Bolivia(Plurinational State of)', 'id' => '068', 'iso_alpha2' => 'BO', 'iso_alpha3' => 'BOL']); + Country::create(['region_id' => '005', 'name' => 'Bouvet Island', 'id' => '074', 'iso_alpha2' => 'BV', 'iso_alpha3' => 'BVT']); + Country::create(['region_id' => '005', 'name' => 'Brazil', 'id' => '076', 'iso_alpha2' => 'BR', 'iso_alpha3' => 'BRA']); + Country::create(['region_id' => '005', 'name' => 'Chile', 'id' => '152', 'iso_alpha2' => 'CL', 'iso_alpha3' => 'CHL']); + Country::create(['region_id' => '005', 'name' => 'Colombia', 'id' => '170', 'iso_alpha2' => 'CO', 'iso_alpha3' => 'COL']); + Country::create(['region_id' => '005', 'name' => 'Ecuador', 'id' => '218', 'iso_alpha2' => 'EC', 'iso_alpha3' => 'ECU']); + Country::create(['region_id' => '005', 'name' => 'Falkland Islands(Malvinas)', 'id' => '238', 'iso_alpha2' => 'FK', 'iso_alpha3' => 'FLK']); + Country::create(['region_id' => '005', 'name' => 'French Guiana', 'id' => '254', 'iso_alpha2' => 'GF', 'iso_alpha3' => 'GUF']); + Country::create(['region_id' => '005', 'name' => 'Guyana', 'id' => '328', 'iso_alpha2' => 'GY', 'iso_alpha3' => 'GUY']); + Country::create(['region_id' => '005', 'name' => 'Paraguay', 'id' => '600', 'iso_alpha2' => 'PY', 'iso_alpha3' => 'PRY']); + Country::create(['region_id' => '005', 'name' => 'Peru', 'id' => '604', 'iso_alpha2' => 'PE', 'iso_alpha3' => 'PER']); + Country::create(['region_id' => '005', 'name' => 'South Georgia and the South Sandwich Islands', 'id' => '239', 'iso_alpha2' => 'GS', 'iso_alpha3' => 'SGS']); + Country::create(['region_id' => '005', 'name' => 'Suriname', 'id' => '740', 'iso_alpha2' => 'SR', 'iso_alpha3' => 'SUR']); + Country::create(['region_id' => '005', 'name' => 'Uruguay', 'id' => '858', 'iso_alpha2' => 'UY', 'iso_alpha3' => 'URY']); + Country::create(['region_id' => '005', 'name' => 'Venezuela (Bolivarian Republic of)', 'id' => '862', 'iso_alpha2' => 'VE', 'iso_alpha3' => 'VEN']); + Country::create(['region_id' => '021', 'name' => 'Bermuda', 'id' => '060', 'iso_alpha2' => 'BM', 'iso_alpha3' => 'BMU']); + Country::create(['region_id' => '021', 'name' => 'Canada', 'id' => '124', 'iso_alpha2' => 'CA', 'iso_alpha3' => 'CAN']); + Country::create(['region_id' => '021', 'name' => 'Greenland', 'id' => '304', 'iso_alpha2' => 'GL', 'iso_alpha3' => 'GRL']); + Country::create(['region_id' => '021', 'name' => 'Saint Pierre and Miquelon', 'id' => '666', 'iso_alpha2' => 'PM', 'iso_alpha3' => 'SPM']); + Country::create(['region_id' => '021', 'name' => 'United States of America', 'id' => '840', 'iso_alpha2' => 'US', 'iso_alpha3' => 'USA']); + Country::create(['region_id' => '000', 'name' => 'Antarctica', 'id' => '010', 'iso_alpha2' => 'AQ', 'iso_alpha3' => 'ATA']); + Country::create(['region_id' => '143', 'name' => 'Kazakhstan', 'id' => '398', 'iso_alpha2' => 'KZ', 'iso_alpha3' => 'KAZ']); + Country::create(['region_id' => '143', 'name' => 'Kyrgyzstan', 'id' => '417', 'iso_alpha2' => 'KG', 'iso_alpha3' => 'KGZ']); + Country::create(['region_id' => '143', 'name' => 'Tajikistan', 'id' => '762', 'iso_alpha2' => 'TJ', 'iso_alpha3' => 'TJK']); + Country::create(['region_id' => '143', 'name' => 'Turkmenistan', 'id' => '795', 'iso_alpha2' => 'TM', 'iso_alpha3' => 'TKM']); + Country::create(['region_id' => '143', 'name' => 'Uzbekistan', 'id' => '860', 'iso_alpha2' => 'UZ', 'iso_alpha3' => 'UZB']); + Country::create(['region_id' => '030', 'name' => 'China', 'id' => '156', 'iso_alpha2' => 'CN', 'iso_alpha3' => 'CHN']); + Country::create(['region_id' => '030', 'name' => 'China, Hong Kong Special Administrative Region', 'id' => '344', 'iso_alpha2' => 'HK', 'iso_alpha3' => 'HKG']); + Country::create(['region_id' => '030', 'name' => 'China, Macao Special Administrative Region', 'id' => '446', 'iso_alpha2' => 'MO', 'iso_alpha3' => 'MAC']); + Country::create(['region_id' => '030', 'name' => "Democratic People's Republic of Korea", 'id' => '408', 'iso_alpha2' => 'KP', 'iso_alpha3' => 'PRK']); + Country::create(['region_id' => '030', 'name' => 'Japan', 'id' => '392', 'iso_alpha2' => 'JP', 'iso_alpha3' => 'JPN']); + Country::create(['region_id' => '030', 'name' => 'Mongolia', 'id' => '496', 'iso_alpha2' => 'MN', 'iso_alpha3' => 'MNG']); + Country::create(['region_id' => '030', 'name' => 'Republic of Korea', 'id' => '410', 'iso_alpha2' => 'KR', 'iso_alpha3' => 'KOR']); + Country::create(['region_id' => '035', 'name' => 'Brunei Darussalam', 'id' => '096', 'iso_alpha2' => 'BN', 'iso_alpha3' => 'BRN']); + Country::create(['region_id' => '035', 'name' => 'Cambodia', 'id' => '116', 'iso_alpha2' => 'KH', 'iso_alpha3' => 'KHM']); + Country::create(['region_id' => '035', 'name' => 'Indonesia', 'id' => '360', 'iso_alpha2' => 'ID', 'iso_alpha3' => 'IDN']); + Country::create(['region_id' => '035', 'name' => "Lao People's Democratic Republic", 'id' => '418', 'iso_alpha2' => 'LA', 'iso_alpha3' => 'LAO']); + Country::create(['region_id' => '035', 'name' => 'Malaysia', 'id' => '458', 'iso_alpha2' => 'MY', 'iso_alpha3' => 'MYS']); + Country::create(['region_id' => '035', 'name' => 'Myanmar', 'id' => '104', 'iso_alpha2' => 'MM', 'iso_alpha3' => 'MMR']); + Country::create(['region_id' => '035', 'name' => 'Philippines', 'id' => '608', 'iso_alpha2' => 'PH', 'iso_alpha3' => 'PHL']); + Country::create(['region_id' => '035', 'name' => 'Singapore', 'id' => '702', 'iso_alpha2' => 'SG', 'iso_alpha3' => 'SGP']); + Country::create(['region_id' => '035', 'name' => 'Thailand', 'id' => '764', 'iso_alpha2' => 'TH', 'iso_alpha3' => 'THA']); + Country::create(['region_id' => '035', 'name' => 'Timor - Leste', 'id' => '626', 'iso_alpha2' => 'TL', 'iso_alpha3' => 'TLS']); + Country::create(['region_id' => '035', 'name' => 'Viet Nam', 'id' => '704', 'iso_alpha2' => 'VN', 'iso_alpha3' => 'VNM']); + Country::create(['region_id' => '034', 'name' => 'Afghanistan', 'id' => '004', 'iso_alpha2' => 'AF', 'iso_alpha3' => 'AFG']); + Country::create(['region_id' => '034', 'name' => 'Bangladesh', 'id' => '050', 'iso_alpha2' => 'BD', 'iso_alpha3' => 'BGD']); + Country::create(['region_id' => '034', 'name' => 'Bhutan', 'id' => '064', 'iso_alpha2' => 'BT', 'iso_alpha3' => 'BTN']); + Country::create(['region_id' => '034', 'name' => 'India', 'id' => '356', 'iso_alpha2' => 'IN', 'iso_alpha3' => 'IND']); + Country::create(['region_id' => '034', 'name' => 'Iran(Islamic Republic of)', 'id' => '364', 'iso_alpha2' => 'IR', 'iso_alpha3' => 'IRN']); + Country::create(['region_id' => '034', 'name' => 'Maldives', 'id' => '462', 'iso_alpha2' => 'MV', 'iso_alpha3' => 'MDV']); + Country::create(['region_id' => '034', 'name' => 'Nepal', 'id' => '524', 'iso_alpha2' => 'NP', 'iso_alpha3' => 'NPL']); + Country::create(['region_id' => '034', 'name' => 'Pakistan', 'id' => '586', 'iso_alpha2' => 'PK', 'iso_alpha3' => 'PAK']); + Country::create(['region_id' => '034', 'name' => 'Sri Lanka', 'id' => '144', 'iso_alpha2' => 'LK', 'iso_alpha3' => 'LKA']); + Country::create(['region_id' => '145', 'name' => 'Armenia', 'id' => '051', 'iso_alpha2' => 'AM', 'iso_alpha3' => 'ARM']); + Country::create(['region_id' => '145', 'name' => 'Azerbaijan', 'id' => '031', 'iso_alpha2' => 'AZ', 'iso_alpha3' => 'AZE']); + Country::create(['region_id' => '145', 'name' => 'Bahrain', 'id' => '048', 'iso_alpha2' => 'BH', 'iso_alpha3' => 'BHR']); + Country::create(['region_id' => '145', 'name' => 'Cyprus', 'id' => '196', 'iso_alpha2' => 'CY', 'iso_alpha3' => 'CYP']); + Country::create(['region_id' => '145', 'name' => 'Georgia', 'id' => '268', 'iso_alpha2' => 'GE', 'iso_alpha3' => 'GEO']); + Country::create(['region_id' => '145', 'name' => 'Iraq', 'id' => '368', 'iso_alpha2' => 'IQ', 'iso_alpha3' => 'IRQ']); + Country::create(['region_id' => '145', 'name' => 'Israel', 'id' => '376', 'iso_alpha2' => 'IL', 'iso_alpha3' => 'ISR']); + Country::create(['region_id' => '145', 'name' => 'Jordan', 'id' => '400', 'iso_alpha2' => 'JO', 'iso_alpha3' => 'JOR']); + Country::create(['region_id' => '145', 'name' => 'Kuwait', 'id' => '414', 'iso_alpha2' => 'KW', 'iso_alpha3' => 'KWT']); + Country::create(['region_id' => '145', 'name' => 'Lebanon', 'id' => '422', 'iso_alpha2' => 'LB', 'iso_alpha3' => 'LBN']); + Country::create(['region_id' => '145', 'name' => 'Oman', 'id' => '512', 'iso_alpha2' => 'OM', 'iso_alpha3' => 'OMN']); + Country::create(['region_id' => '145', 'name' => 'Qatar', 'id' => '634', 'iso_alpha2' => 'QA', 'iso_alpha3' => 'QAT']); + Country::create(['region_id' => '145', 'name' => 'Saudi Arabia', 'id' => '682', 'iso_alpha2' => 'SA', 'iso_alpha3' => 'SAU']); + Country::create(['region_id' => '145', 'name' => 'State of Palestine', 'id' => '275', 'iso_alpha2' => 'PS', 'iso_alpha3' => 'PSE']); + Country::create(['region_id' => '145', 'name' => 'Syrian Arab Republic', 'id' => '760', 'iso_alpha2' => 'SY', 'iso_alpha3' => 'SYR']); + Country::create(['region_id' => '145', 'name' => 'Türkiye', 'id' => '792', 'iso_alpha2' => 'TR', 'iso_alpha3' => 'TUR']); + Country::create(['region_id' => '145', 'name' => 'United Arab Emirates', 'id' => '784', 'iso_alpha2' => 'AE', 'iso_alpha3' => 'ARE']); + Country::create(['region_id' => '145', 'name' => 'Yemen', 'id' => '887', 'iso_alpha2' => 'YE', 'iso_alpha3' => 'YEM']); + Country::create(['region_id' => '151', 'name' => 'Belarus', 'id' => '112', 'iso_alpha2' => 'BY', 'iso_alpha3' => 'BLR']); + Country::create(['region_id' => '151', 'name' => 'Bulgaria', 'id' => '100', 'iso_alpha2' => 'BG', 'iso_alpha3' => 'BGR']); + Country::create(['region_id' => '151', 'name' => 'Czechia', 'id' => '203', 'iso_alpha2' => 'CZ', 'iso_alpha3' => 'CZE']); + Country::create(['region_id' => '151', 'name' => 'Hungary', 'id' => '348', 'iso_alpha2' => 'HU', 'iso_alpha3' => 'HUN']); + Country::create(['region_id' => '151', 'name' => 'Poland', 'id' => '616', 'iso_alpha2' => 'PL', 'iso_alpha3' => 'POL']); + Country::create(['region_id' => '151', 'name' => 'Republic of Moldova', 'id' => '498', 'iso_alpha2' => 'MD', 'iso_alpha3' => 'MDA']); + Country::create(['region_id' => '151', 'name' => 'Romania', 'id' => '642', 'iso_alpha2' => 'RO', 'iso_alpha3' => 'ROU']); + Country::create(['region_id' => '151', 'name' => 'Russian Federation', 'id' => '643', 'iso_alpha2' => 'RU', 'iso_alpha3' => 'RUS']); + Country::create(['region_id' => '151', 'name' => 'Slovakia', 'id' => '703', 'iso_alpha2' => 'SK', 'iso_alpha3' => 'SVK']); + Country::create(['region_id' => '151', 'name' => 'Ukraine', 'id' => '804', 'iso_alpha2' => 'UA', 'iso_alpha3' => 'UKR']); + Country::create(['region_id' => '154', 'name' => 'Åland Islands', 'id' => '248', 'iso_alpha2' => 'AX', 'iso_alpha3' => 'ALA']); + Country::create(['region_id' => '830', 'name' => 'Guernsey', 'id' => '831', 'iso_alpha2' => 'GG', 'iso_alpha3' => 'GGY']); + Country::create(['region_id' => '830', 'name' => 'Jersey', 'id' => '832', 'iso_alpha2' => 'JE', 'iso_alpha3' => 'JEY']); + Country::create(['region_id' => '830', 'name' => 'Sark', 'id' => '680', 'iso_alpha2' => '', 'iso_alpha3' => '']); + Country::create(['region_id' => '154', 'name' => 'Denmark', 'id' => '208', 'iso_alpha2' => 'DK', 'iso_alpha3' => 'DNK']); + Country::create(['region_id' => '154', 'name' => 'Estonia', 'id' => '233', 'iso_alpha2' => 'EE', 'iso_alpha3' => 'EST']); + Country::create(['region_id' => '154', 'name' => 'Faroe Islands', 'id' => '234', 'iso_alpha2' => 'FO', 'iso_alpha3' => 'FRO']); + Country::create(['region_id' => '154', 'name' => 'Finland', 'id' => '246', 'iso_alpha2' => 'FI', 'iso_alpha3' => 'FIN']); + Country::create(['region_id' => '154', 'name' => 'Iceland', 'id' => '352', 'iso_alpha2' => 'IS', 'iso_alpha3' => 'ISL']); + Country::create(['region_id' => '154', 'name' => 'Ireland', 'id' => '372', 'iso_alpha2' => 'IE', 'iso_alpha3' => 'IRL']); + Country::create(['region_id' => '154', 'name' => 'Isle of Man', 'id' => '833', 'iso_alpha2' => 'IM', 'iso_alpha3' => 'IMN']); + Country::create(['region_id' => '154', 'name' => 'Latvia', 'id' => '428', 'iso_alpha2' => 'LV', 'iso_alpha3' => 'LVA']); + Country::create(['region_id' => '154', 'name' => 'Lithuania', 'id' => '440', 'iso_alpha2' => 'LT', 'iso_alpha3' => 'LTU']); + Country::create(['region_id' => '154', 'name' => 'Norway', 'id' => '578', 'iso_alpha2' => 'NO', 'iso_alpha3' => 'NOR']); + Country::create(['region_id' => '154', 'name' => 'Svalbard and Jan Mayen Islands', 'id' => '744', 'iso_alpha2' => 'SJ', 'iso_alpha3' => 'SJM']); + Country::create(['region_id' => '154', 'name' => 'Sweden', 'id' => '752', 'iso_alpha2' => 'SE', 'iso_alpha3' => 'SWE']); + Country::create(['region_id' => '154', 'name' => 'United Kingdom of Great Britain and Northern Ireland', 'id' => '826', 'iso_alpha2' => 'GB', 'iso_alpha3' => 'GBR']); + Country::create(['region_id' => '039', 'name' => 'Albania', 'id' => '008', 'iso_alpha2' => 'AL', 'iso_alpha3' => 'ALB']); + Country::create(['region_id' => '039', 'name' => 'Andorra', 'id' => '020', 'iso_alpha2' => 'AD', 'iso_alpha3' => 'AND']); + Country::create(['region_id' => '039', 'name' => 'Bosnia and Herzegovina', 'id' => '070', 'iso_alpha2' => 'BA', 'iso_alpha3' => 'BIH']); + Country::create(['region_id' => '039', 'name' => 'Croatia', 'id' => '191', 'iso_alpha2' => 'HR', 'iso_alpha3' => 'HRV']); + Country::create(['region_id' => '039', 'name' => 'Gibraltar', 'id' => '292', 'iso_alpha2' => 'GI', 'iso_alpha3' => 'GIB']); + Country::create(['region_id' => '039', 'name' => 'Greece', 'id' => '300', 'iso_alpha2' => 'GR', 'iso_alpha3' => 'GRC']); + Country::create(['region_id' => '039', 'name' => 'Holy See', 'id' => '336', 'iso_alpha2' => 'VA', 'iso_alpha3' => 'VAT']); + Country::create(['region_id' => '039', 'name' => 'Italy', 'id' => '380', 'iso_alpha2' => 'IT', 'iso_alpha3' => 'ITA']); + Country::create(['region_id' => '039', 'name' => 'Malta', 'id' => '470', 'iso_alpha2' => 'MT', 'iso_alpha3' => 'MLT']); + Country::create(['region_id' => '039', 'name' => 'Montenegro', 'id' => '499', 'iso_alpha2' => 'ME', 'iso_alpha3' => 'MNE']); + Country::create(['region_id' => '039', 'name' => 'North Macedonia', 'id' => '807', 'iso_alpha2' => 'MK', 'iso_alpha3' => 'MKD']); + Country::create(['region_id' => '039', 'name' => 'Portugal', 'id' => '620', 'iso_alpha2' => 'PT', 'iso_alpha3' => 'PRT']); + Country::create(['region_id' => '039', 'name' => 'San Marino', 'id' => '674', 'iso_alpha2' => 'SM', 'iso_alpha3' => 'SMR']); + Country::create(['region_id' => '039', 'name' => 'Serbia', 'id' => '688', 'iso_alpha2' => 'RS', 'iso_alpha3' => 'SRB']); + Country::create(['region_id' => '039', 'name' => 'Slovenia', 'id' => '705', 'iso_alpha2' => 'SI', 'iso_alpha3' => 'SVN']); + Country::create(['region_id' => '039', 'name' => 'Spain', 'id' => '724', 'iso_alpha2' => 'ES', 'iso_alpha3' => 'ESP']); + Country::create(['region_id' => '155', 'name' => 'Austria', 'id' => '040', 'iso_alpha2' => 'AT', 'iso_alpha3' => 'AUT']); + Country::create(['region_id' => '155', 'name' => 'Belgium', 'id' => '056', 'iso_alpha2' => 'BE', 'iso_alpha3' => 'BEL']); + Country::create(['region_id' => '155', 'name' => 'France', 'id' => '250', 'iso_alpha2' => 'FR', 'iso_alpha3' => 'FRA']); + Country::create(['region_id' => '155', 'name' => 'Germany', 'id' => '276', 'iso_alpha2' => 'DE', 'iso_alpha3' => 'DEU']); + Country::create(['region_id' => '155', 'name' => 'Liechtenstein', 'id' => '438', 'iso_alpha2' => 'LI', 'iso_alpha3' => 'LIE']); + Country::create(['region_id' => '155', 'name' => 'Luxembourg', 'id' => '442', 'iso_alpha2' => 'LU', 'iso_alpha3' => 'LUX']); + Country::create(['region_id' => '155', 'name' => 'Monaco', 'id' => '492', 'iso_alpha2' => 'MC', 'iso_alpha3' => 'MCO']); + Country::create(['region_id' => '155', 'name' => 'Netherlands', 'id' => '528', 'iso_alpha2' => 'NL', 'iso_alpha3' => 'NLD']); + Country::create(['region_id' => '155', 'name' => 'Switzerland', 'id' => '756', 'iso_alpha2' => 'CH', 'iso_alpha3' => 'CHE']); + Country::create(['region_id' => '053', 'name' => 'Australia', 'id' => '036', 'iso_alpha2' => 'AU', 'iso_alpha3' => 'AUS']); + Country::create(['region_id' => '053', 'name' => 'Christmas Island', 'id' => '162', 'iso_alpha2' => 'CX', 'iso_alpha3' => 'CXR']); + Country::create(['region_id' => '053', 'name' => 'Cocos(Keeling) Islands', 'id' => '166', 'iso_alpha2' => 'CC', 'iso_alpha3' => 'CCK']); + Country::create(['region_id' => '053', 'name' => 'Heard Island and McDonald Islands', 'id' => '334', 'iso_alpha2' => 'HM', 'iso_alpha3' => 'HMD']); + Country::create(['region_id' => '053', 'name' => 'new Zealand', 'id' => '554', 'iso_alpha2' => 'NZ', 'iso_alpha3' => 'NZL']); + Country::create(['region_id' => '053', 'name' => 'Norfolk Island', 'id' => '574', 'iso_alpha2' => 'NF', 'iso_alpha3' => 'NFK']); + Country::create(['region_id' => '054', 'name' => 'Fiji', 'id' => '242', 'iso_alpha2' => 'FJ', 'iso_alpha3' => 'FJI']); + Country::create(['region_id' => '054', 'name' => 'new Caledonia', 'id' => '540', 'iso_alpha2' => 'NC', 'iso_alpha3' => 'NCL']); + Country::create(['region_id' => '054', 'name' => 'Papua new Guinea', 'id' => '598', 'iso_alpha2' => 'PG', 'iso_alpha3' => 'PNG']); + Country::create(['region_id' => '054', 'name' => 'Solomon Islands', 'id' => '090', 'iso_alpha2' => 'SB', 'iso_alpha3' => 'SLB']); + Country::create(['region_id' => '054', 'name' => 'Vanuatu', 'id' => '548', 'iso_alpha2' => 'VU', 'iso_alpha3' => 'VUT']); + Country::create(['region_id' => '057', 'name' => 'Guam', 'id' => '316', 'iso_alpha2' => 'GU', 'iso_alpha3' => 'GUM']); + Country::create(['region_id' => '057', 'name' => 'Kiribati', 'id' => '296', 'iso_alpha2' => 'KI', 'iso_alpha3' => 'KIR']); + Country::create(['region_id' => '057', 'name' => 'Marshall Islands', 'id' => '584', 'iso_alpha2' => 'MH', 'iso_alpha3' => 'MHL']); + Country::create(['region_id' => '057', 'name' => 'Micronesia(Federated States of)', 'id' => '583', 'iso_alpha2' => 'FM', 'iso_alpha3' => 'FSM']); + Country::create(['region_id' => '057', 'name' => 'Nauru', 'id' => '520', 'iso_alpha2' => 'NR', 'iso_alpha3' => 'NRU']); + Country::create(['region_id' => '057', 'name' => 'Northern Mariana Islands', 'id' => '580', 'iso_alpha2' => 'MP', 'iso_alpha3' => 'MNP']); + Country::create(['region_id' => '057', 'name' => 'Palau', 'id' => '585', 'iso_alpha2' => 'PW', 'iso_alpha3' => 'PLW']); + Country::create(['region_id' => '057', 'name' => 'United States Minor Outlying Islands', 'id' => '581', 'iso_alpha2' => 'UM', 'iso_alpha3' => 'UMI']); + Country::create(['region_id' => '061', 'name' => 'American Samoa', 'id' => '016', 'iso_alpha2' => 'as', 'iso_alpha3' => 'ASM']); + Country::create(['region_id' => '061', 'name' => 'Cook Islands', 'id' => '184', 'iso_alpha2' => 'CK', 'iso_alpha3' => 'COK']); + Country::create(['region_id' => '061', 'name' => 'French Polynesia', 'id' => '258', 'iso_alpha2' => 'PF', 'iso_alpha3' => 'PYF']); + Country::create(['region_id' => '061', 'name' => 'Niue', 'id' => '570', 'iso_alpha2' => 'NU', 'iso_alpha3' => 'NIU']); + Country::create(['region_id' => '061', 'name' => 'Pitcairn', 'id' => '612', 'iso_alpha2' => 'PN', 'iso_alpha3' => 'PCN']); + Country::create(['region_id' => '061', 'name' => 'Samoa', 'id' => '882', 'iso_alpha2' => 'WS', 'iso_alpha3' => 'WSM']); + Country::create(['region_id' => '061', 'name' => 'Tokelau', 'id' => '772', 'iso_alpha2' => 'TK', 'iso_alpha3' => 'TKL']); + Country::create(['region_id' => '061', 'name' => 'Tonga', 'id' => '776', 'iso_alpha2' => 'TO', 'iso_alpha3' => 'TON']); + Country::create(['region_id' => '061', 'name' => 'Tuvalu', 'id' => '798', 'iso_alpha2' => 'TV', 'iso_alpha3' => 'TUV']); + Country::create(['region_id' => '061', 'name' => 'Wallis and Futuna Islands', 'id' => '876', 'iso_alpha2' => 'WF', 'iso_alpha3' => 'WLF']); + } +} diff --git a/database/views/crop_list_with_metadata.sql b/database/views/crop_list_with_metadata.sql new file mode 100644 index 00000000..10127214 --- /dev/null +++ b/database/views/crop_list_with_metadata.sql @@ -0,0 +1,17 @@ +SELECT + crop_list_entries.id as id, + if(choice_list_entries.owner_id is null, 1, 0) as `is_global_entry`, + choice_list_entries.owner_id as team_id, + choice_list_entries.name as name, + language_strings.text as label_en, + crop_list_entries.expected_yield as expected_yield, + crop_list_entries.recommended_fert_use as recommended_fert_use + +from crop_list_entries +left join choice_list_entries on crop_list_entries.choice_list_entry_id = choice_list_entries.id +left join language_strings on + linked_entry_id = choice_list_entries.id + # only label strings + and language_strings.language_string_type_id = (SELECT id from language_string_types where name = 'label') + # only english strings + and xlsform_template_language_id = (SELECT id from xlsform_template_languages where xlsform_template_languages.language_id = (SELECT id from languages where iso_alpha2 = "en" limit 1) limit 1); diff --git a/database/views/example.sql b/database/views/example.sql new file mode 100644 index 00000000..aed87264 --- /dev/null +++ b/database/views/example.sql @@ -0,0 +1,5 @@ +SELECT + users.id, + users.name +FROM users +WHERE users.email_verified_at is NULL; \ No newline at end of file diff --git a/packages/filament-odk-link b/packages/filament-odk-link index 7c6d0a3d..65ec15a5 160000 --- a/packages/filament-odk-link +++ b/packages/filament-odk-link @@ -1 +1 @@ -Subproject commit 7c6d0a3d3cb0c954e62619dbbcefa0386507d52d +Subproject commit 65ec15a59a63b44538805478e714868bf75abbe4 diff --git a/resources/views/filament/app/clusters/lookup-tables/resources/choice-list-entry-resource/widgets/choice-list-entries-info.blade.php b/resources/views/filament/app/clusters/lookup-tables/resources/choice-list-entry-resource/widgets/choice-list-entries-info.blade.php new file mode 100644 index 00000000..dc12b9eb --- /dev/null +++ b/resources/views/filament/app/clusters/lookup-tables/resources/choice-list-entry-resource/widgets/choice-list-entries-info.blade.php @@ -0,0 +1,24 @@ + + + The list below will be included in the questionnaire as a choice list. You can add, edit, and delete entries here, and the list will be updated in the questionnaire automatically. + + + + +
    + +
  • + Variable Name: + Question text + @foreach($surveyRows as $surveyRow) +
  • + {{ $surveyRow['name'] }}: + {{ $surveyRow['label'] }} +
  • + @endforeach + +
+
+ + +
diff --git a/resources/views/filament/app/pages/list-records.blade.php b/resources/views/filament/app/pages/list-records.blade.php new file mode 100644 index 00000000..389c0f97 --- /dev/null +++ b/resources/views/filament/app/pages/list-records.blade.php @@ -0,0 +1,18 @@ +getResource()::getSlug()), + ]) +> +
+ + + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_BEFORE, scopes: $this->getRenderHookScopes()) }} + + {{ $this->tableInfolist }} + + {{ $this->table }} + + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_AFTER, scopes: $this->getRenderHookScopes()) }} +
+
diff --git a/tests/Feature/XlsformTemplateImportTest.php b/tests/Feature/XlsformTemplateImportTest.php index 5aa5d77c..6abff8bd 100644 --- a/tests/Feature/XlsformTemplateImportTest.php +++ b/tests/Feature/XlsformTemplateImportTest.php @@ -11,14 +11,6 @@ (new HandleXlsformTemplateAdded())->processXlsformTemplate('tests/assets/odk-example-form-1.xlsx', $this->xlsformTemplate); - ray(LanguageString::all() - ->map(fn($languageString) => [ - 'text' => $languageString->text, - 'language' => $languageString->xlsformTemplateLanguage->language->iso_alpha2, - 'type' => $languageString->languageStringType->name, - ]) - ->groupBy('language')); - // check that the survey rows were imported correctly $this->assertDatabaseCount('survey_rows', 3); $this->assertDatabaseCount('choice_lists', 3);