Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pets-api/app/Http/Requests/PetRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function rules(): array
'castracao' => 'nullable|date',
'mae_id' => 'nullable|exists:pets,id',
'pai_id' => 'nullable|exists:pets,id',
'atributos' => 'nullable|array',
];
}
}
2 changes: 2 additions & 0 deletions pets-api/app/Models/Pet.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Pet extends Model
'castracao',
'mae_id',
'pai_id',
'atributos',
];

/**
Expand All @@ -85,6 +86,7 @@ class Pet extends Model
'nascimento' => 'datetime',
'falecimento' => 'datetime',
'castracao' => 'datetime',
'atributos' => 'array',
];

/**
Expand Down
6 changes: 6 additions & 0 deletions pets-api/database/factories/PetFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public function definition(): array
'nascimento' => $this->faker->dateTimeBetween('-10 years', '-1 year'),
'falecimento' => $this->faker->dateTimeBetween('-1 year', 'now'),
'castracao' => $this->faker->dateTimeBetween('-1 year', 'now'),
'atributos' => [
'cor' => $this->faker->randomElement(['preto', 'branco', 'marrom']),
'pelagem' => $this->faker->randomElement(['curta', 'longa']),
'porte' => $this->faker->randomElement(['pequeno', 'medio', 'grande']),
'temperamento' => $this->faker->randomElement(['calmo', 'agressivo', 'brincalhao']),
],
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('pets', function (Blueprint $table) {
$table->json('atributos')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('pets', function (Blueprint $table) {
$table->dropColumn('atributos');
});
}
};
4 changes: 4 additions & 0 deletions pets-api/tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
Illuminate\Foundation\Testing\RefreshDatabase::class,
)->in('Feature');

uses(
Tests\TestCase::class,
)->in('Unit');

/*
|--------------------------------------------------------------------------
| Expectations
Expand Down
27 changes: 27 additions & 0 deletions pets-api/tests/Unit/Models/PetTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use App\Models\Pet;
use function PHPUnit\Framework\assertEquals;

/**
* Cobre fillable e cast da prop atributo "atributos" do modelo Pet.
*/
test('consigo ler e escrever atributos', function () {
$pet = Pet::factory()->create();

$pet->fill([
'atributos' => [
'cor' => 'preto',
'pelagem' => 'curta',
'porte' => 'pequeno',
'temperamento' => 'calmo',
],
]);

assertEquals($pet->atributos, [
'cor' => 'preto',
'pelagem' => 'curta',
'porte' => 'pequeno',
'temperamento' => 'calmo',
]);
});
11 changes: 11 additions & 0 deletions pets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

# Atualizando Traduções

Para atualizar as traduções do seu aplicativo Flutter, siga os passos abaixo:

1. Adicione o novo texto no arquivo de localização (geralmente `lib/l10n/app_en.arb` para inglês).
2. Traduza o texto para os idiomas suportados adicionando entradas correspondentes nos respectivos arquivos de localização (como `lib/l10n/app_pt.arb` para português).
3. Execute o comando `flutter gen-l10n` no terminal para gerar os arquivos de classe de localização.
4. Use as classes geradas para exibir texto traduzido em seu aplicativo.

Lembre-se de que você precisa ter a internacionalização configurada em seu projeto Flutter para usar esse recurso. Se você ainda não configurou, consulte a [documentação de internacionalização do Flutter](https://flutter.dev/docs/development/accessibility-and-localization/internationalization).
3 changes: 2 additions & 1 deletion pets/l10n.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
output-localization-file: app_localizations.dart
untranslated-messages-file: untranslated_messages.json
3 changes: 2 additions & 1 deletion pets/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,6 @@
"placeholderProximos4": "Appointments can be ",
"placeholderProximos5": "repetitions for routine tasks",
"placeholderProximos6": " or ",
"placeholderProximos7": "by quantity, like doses in medications.\n"
"placeholderProximos7": "by quantity, like doses in medications.\n",
"petsNewField": "New field"
}
6 changes: 5 additions & 1 deletion pets/lib/l10n/app_pt.arb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
"sharedUnknown": "Desconhecido",
"sharedCancel": "Cancelar",
"sharedExclude": "Excluir",
"sharedMale": "Macho",
"sharedFemale": "Fêmea",
"dashboardMyPets": "Meus pets",
"dashboardTodo": "A fazer",
"dashboardTimeline": "Linha do tempo",
"medicineMain": "Principal",
"medicineType": "Tipo",
"medicinePrefixOn": "Em ",
"medicineAnimal": "Animal",
Expand Down Expand Up @@ -86,5 +89,6 @@
"placeholderProximos4": "Os agendamentos podem ",
"placeholderProximos5": "ser repetições para tarefas rotineiras",
"placeholderProximos6": " ou ",
"placeholderProximos7": "por quantidade como as doses em medicamentos.\n"
"placeholderProximos7": "por quantidade como as doses em medicamentos.\n",
"petsNewField": "Novo campo"
}
1 change: 1 addition & 0 deletions pets/lib/models/pet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Pet with _$Pet {
@JsonKey(name: 'espaco_id') required String? espacoId,
String? falecimento,
@JsonKey(name: 'imagem_url') String? imagemUrl,
@Default({}) Map<String, String>? atributos,
}) = _Pet;

Uri? get imagemUri {
Expand Down
89 changes: 61 additions & 28 deletions pets/lib/models/pet.freezed.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pets/lib/models/pet.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pets/untranslated_messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}