CRM - tp 1,2, et 3 bientot fini refresh
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?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('clients', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email') ->unique();
|
||||
$table->string('city');
|
||||
$table->string('address') ->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('clients');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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('product', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->unsignedInteger('price');
|
||||
$table->unsignedInteger('stock');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Schema::create('clients', function (Blueprint $table) {
|
||||
// $table->id();
|
||||
// $table->string('name');
|
||||
// $table->string('email') ->unique();
|
||||
// $table->string('city');
|
||||
// $table->string('address') ->nullable();
|
||||
// $table->timestamps();
|
||||
// });
|
||||
// }
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('product');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
use App\Models\Client;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ClientSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Client::create([
|
||||
'name' => 'Jean Dupont',
|
||||
'email' => 'jean@example.com',
|
||||
'city' => 'Paris'
|
||||
]);
|
||||
Client::create([
|
||||
'name' => 'Marie Martin',
|
||||
'email' => 'marie@example.com',
|
||||
'city' => 'Lyon'
|
||||
]);
|
||||
Client::create([
|
||||
'name' => 'Paul Durand',
|
||||
'email' => 'paul@example.com',
|
||||
'city' => 'Bordeaux'
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,15 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
// // User::factory(10)->create();
|
||||
// $this->call([
|
||||
// ClientSeeder::class,
|
||||
// ]);
|
||||
|
||||
$this->call([
|
||||
ProductSeeder::class,
|
||||
]);
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Product;
|
||||
|
||||
class ProductSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Product::create([
|
||||
'name' => 'Ordinateur',
|
||||
'price' => 899,
|
||||
'stock' => 12
|
||||
]);
|
||||
|
||||
Product::create([
|
||||
'name' => 'Écran',
|
||||
'price' => 249,
|
||||
'stock' => 7
|
||||
]);
|
||||
|
||||
Product::create([
|
||||
'name' => 'Clavier',
|
||||
'price' => 79,
|
||||
'stock' => 25
|
||||
]);
|
||||
|
||||
Product::create([
|
||||
'name' => 'Souris',
|
||||
'price' => 39,
|
||||
'stock' => 42
|
||||
]);
|
||||
|
||||
Product::create([
|
||||
'name' => 'Webcam',
|
||||
'price' => 99,
|
||||
'stock' => 4
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user