This commit is contained in:
2023-03-03 13:45:51 +01:00
parent 7a06ea248e
commit 3d13369e05
92 changed files with 15859 additions and 66 deletions

1
database/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.sqlite*

View File

@@ -0,0 +1,42 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name(),
'email' => $this->faker->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function unverified()
{
return $this->state(function (array $attributes) {
return [
'email_verified_at' => null,
];
});
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('failed_jobs');
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('personal_access_tokens');
}
};

View File

@@ -0,0 +1,45 @@
<?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::create('produits', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->string('nom')->nullable();
$table->string('taille')->nullable();
$table->text('description')->nullable();
$table->string('couleur')->nullable();
$table->float('prix')->nullable();
$table->boolean('en_stock')->nullable();
$table->timestamps();
$table->index("nom");
$table->index("taille");
$table->index("couleur");
$table->index("prix");
$table->index("en_stock");
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfexists('produits');
}
};

View File

@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('categories', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->string('nom')->nullable();
$table->timestamps();
$table->index("nom");
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfexists('categories');
}
};

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Query\Expression;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('clients', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->string('nom')->nullable();
$table->string('prenom')->nullable();
$table->json('adresse')->default(new Expression('(JSON_OBJECT())'));
$table->timestamps();
$table->index("nom");
$table->index("prenom");
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfexists('clients');
}
};

View File

@@ -0,0 +1,36 @@
<?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::create('produits_categories', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->bigInteger('products_id')->unsigned();
$table->bigInteger('categories_id')->unsigned();
$table->primary(['products_id', 'categories_id']);
});
Schema::table('produits_categories', function (Blueprint $table) {
$table->foreign('products_id')->references('id')->on('produits')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('categories_id')->references('id')->on('categories')->onUpdate('cascade')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfexists('produits_categories');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Query\Expression;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('commandes', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->date('date')->nullable();
$table->json('adresse')->default(new Expression('(JSON_OBJECT())'));
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfexists('commandes');
}
};

View File

@@ -0,0 +1,39 @@
<?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::create('lignes_commandes', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->bigInteger('commandes_id')->unsigned();
$table->bigInteger('produits_id')->unsigned()->nullable();
$table->integer('quantite')->nullable();
$table->float('prix_vente')->nullable();
$table->timestamps();
});
Schema::table('lignes_commandes', function (Blueprint $table) {
$table->foreign('commandes_id')->references('id')->on('commandes')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('produits_id')->references('id')->on('produits')->onUpdate('cascade')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfexists('lignes_commandes');
}
};

View File

@@ -0,0 +1,19 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
// \App\Models\User::factory(10)->create();
}
}