Skip to content

Commit b57d047

Browse files
create model Card
1 parent ccc01e2 commit b57d047

File tree

9 files changed

+129
-43
lines changed

9 files changed

+129
-43
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Memory;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Http\Request;
7+
8+
class FashCardController extends Controller
9+
{
10+
11+
}

app/Models/Card.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Card extends Model
9+
{
10+
/** @use HasFactory<\Database\Factories\CardFactory> */
11+
use HasFactory;
12+
13+
}

app/Providers/AppServiceProvider.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Providers;
44

5+
use Illuminate\Database\Eloquent\Model;
56
use Illuminate\Support\ServiceProvider;
67

78
class AppServiceProvider extends ServiceProvider
@@ -19,6 +20,15 @@ public function register(): void
1920
*/
2021
public function boot(): void
2122
{
22-
//
23+
Model::preventLazyLoading(! $this->app->isProduction());
24+
25+
// remove validation Fillable Laravel 12
26+
27+
// Remove the need of the property fillable on each model
28+
Model::unguard();
29+
30+
// --
31+
// Make sure that all properties being called exists in the model
32+
Model::shouldBeStrict();
2333
}
2434
}

database/factories/CardFactory.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Database\Factories;
4+
5+
use Illuminate\Database\Eloquent\Factories\Factory;
6+
7+
/**
8+
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Card>
9+
*/
10+
class CardFactory extends Factory
11+
{
12+
/**
13+
* Define the model's default state.
14+
*
15+
* @return array<string, mixed>
16+
*/
17+
public function definition(): array
18+
{
19+
return [
20+
'type' => $this->faker->randomElement(['flashcard', 'text', 'open']),
21+
'title' => $this->faker->sentence(),
22+
'question' => $this->faker->paragraph(),
23+
'answer' => $this->faker->paragraph(),
24+
'content' => $this->faker->paragraph(),
25+
'tags' => $this->faker->words(3, true),
26+
'is_public' => $this->faker->boolean(),
27+
'user_id' => \App\Models\User::factory(),
28+
];
29+
}
30+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('cards', function (Blueprint $table) {
15+
$table->id();
16+
$table->enum('type', ['flashcard', 'text', 'open'])->default('text');
17+
$table->string('title')->nullable();
18+
$table->text('question')->nullable();
19+
$table->text('answer')->nullable();
20+
$table->text('content')->nullable();
21+
// user id
22+
// tags
23+
$table->json('tags')->nullable();
24+
$table->boolean('is_public')->default(false);
25+
$table->foreignId('user_id')->constrained()->onDelete('cascade');
26+
$table->timestamps();
27+
});
28+
}
29+
30+
/**
31+
* Reverse the migrations.
32+
*/
33+
public function down(): void
34+
{
35+
Schema::dropIfExists('cards');
36+
}
37+
};

database/seeders/CardSeeder.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Database\Seeders;
4+
5+
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
6+
use Illuminate\Database\Seeder;
7+
8+
class CardSeeder extends Seeder
9+
{
10+
/**
11+
* Run the database seeds.
12+
*/
13+
public function run(): void
14+
{
15+
\App\Models\Card::factory()
16+
->count(50)
17+
->create();
18+
}
19+
}

database/seeders/DatabaseSeeder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,10 @@ public function run(): void
1919
'name' => 'Test User',
2020
'email' => 'test@example.com',
2121
]);
22+
23+
$this->call([
24+
CardSeeder::class,
25+
// Add other seeders here as needed
26+
]);
2227
}
2328
}

resources/js/components/flashcards/ListMemoriesCard.vue

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Card, CardHeader, CardTitle, CardContent, CardFooter } from '@/componen
44
import { Button } from '@/components/ui/button';
55
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'
66
7-
// add memory
87
</script>
98

109

@@ -96,42 +95,4 @@ The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for t
9695
<Button>Adicionar mais vezes no aprendizado</Button>
9796
</CardFooter> -->
9897
</Card>
99-
</template>
100-
101-
102-
103-
// export default {
104-
105-
// props: {
106-
// memory: {
107-
// type: Object,
108-
// required: true,
109-
// default: () => ({
110-
// id: 1,
111-
// type: 'text-correction',
112-
// date: '25 de Maio de 2025',
113-
// question: 'Explique sobre o que é approach?',
114-
// answer: 'Approach refers to a method or way of dealing with a problem or situation.',
115-
// createdText: 'Tanta petere igitur, ne sineres memini fieri etiam aliquam inclinationem ad consequendum minima.
116-
Instead, oportet omnino quieti de rebus dialecticis differam, et ad cetera munera.',
117-
// correctedText: 'Tanta petere igitur, ne sineres memini fieri etiam aliquam inclinationem ad consequendum minima. Em
118-
vez disso, oportet omnino quieti de rebus dialecticis differam, et ad cetera munera.',
119-
// corrections: [
120-
// { id: 1, detail: 'Substituir "Instead" por "Em vez disso"' }
121-
// ]
122-
// })
123-
// }
124-
// },
125-
// setup() {
126-
// const isExpanded = ref(false);
127-
128-
// const toggleAccordion = () => {
129-
// isExpanded.value = !isExpanded.value;
130-
// };
131-
132-
// return {
133-
// isExpanded,
134-
// toggleAccordion
135-
// };
136-
// }
137-
// };
98+
</template>

resources/js/components/flashcards/NewFlashCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const handleSave = () => {
2727
<Card class="w-full mx-auto p-6 rounded-xl">
2828
<CardContent>
2929
<div class="space-y-6">
30-
<!-- Card Type Selection -->
3130
<div>
3231
<Label for="cardType" class="text-base font-medium block mb-2">Tipo</Label>
3332
<Select v-model="cardType">
@@ -67,7 +66,8 @@ const handleSave = () => {
6766

6867
<CardFooter class="flex justify-end mt-6">
6968
<!-- Adicionar botão de gerar resposta com IA se o cardType for FlashCards -->
70-
<Button variant="outline" v-if="cardType === 'FlashCards'" class="mr-2" @click="() => { /* Logic to generate answer using AI */ }">
69+
<Button variant="outline" v-if="cardType === 'FlashCards'" class="mr-2"
70+
@click="() => { /* Logic to generate answer using AI */ }">
7171
Gerar Resposta com IA
7272
</Button>
7373

0 commit comments

Comments
 (0)