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();
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user