Réalisation du tp3, tp4, tp5 et tp6 avec documentation.
This commit is contained in:
@@ -11,6 +11,7 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// TP3 : structure initiale de la table clients ; le TP5 l'adapte ensuite.
|
||||
Schema::create('clients', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
|
||||
@@ -11,7 +11,8 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('product', function (Blueprint $table) {
|
||||
// TP3 : table products au pluriel, nom attendu par le Model Product.
|
||||
Schema::create('products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->unsignedInteger('price');
|
||||
@@ -35,6 +36,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('product');
|
||||
Schema::dropIfExists('products');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// TP5 : champs facultatifs côté clients et prix décimal côté produits.
|
||||
Schema::table('clients', function (Blueprint $table) {
|
||||
$table->string('phone', 20)->nullable();
|
||||
$table->string('city', 100)->nullable()->change();
|
||||
});
|
||||
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->decimal('price', 10, 2)->change();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('clients', function (Blueprint $table) {
|
||||
$table->dropColumn('phone');
|
||||
$table->string('city')->nullable(false)->change();
|
||||
});
|
||||
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->unsignedInteger('price')->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -12,6 +12,7 @@ class ClientSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// TP3 : trois clients de démonstration pour tester Eloquent et la vue.
|
||||
Client::create([
|
||||
'name' => 'Jean Dupont',
|
||||
'email' => 'jean@example.com',
|
||||
|
||||
@@ -15,15 +15,12 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// // User::factory(10)->create();
|
||||
// $this->call([
|
||||
// ClientSeeder::class,
|
||||
// ]);
|
||||
// TP3 : remplit les tables clients et products avec les exemples du sujet.
|
||||
$this->call([
|
||||
ClientSeeder::class,
|
||||
ProductSeeder::class,
|
||||
]);
|
||||
|
||||
$this->call([
|
||||
ProductSeeder::class,
|
||||
]);
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
|
||||
@@ -12,6 +12,7 @@ class ProductSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// TP3 : cinq produits demandés dans l'exercice final.
|
||||
Product::create([
|
||||
'name' => 'Ordinateur',
|
||||
'price' => 899,
|
||||
@@ -42,4 +43,4 @@ class ProductSeeder extends Seeder
|
||||
'stock' => 4
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user