diff --git a/app/Models/Buildplate.php b/app/Models/Buildplate.php new file mode 100644 index 0000000..132fa9f --- /dev/null +++ b/app/Models/Buildplate.php @@ -0,0 +1,29 @@ +hasMany(Filament::class); + } + + public function manufacturer() + { + return $this->belongsTo(Manufacturer::class); + } + +} diff --git a/app/Models/Extruder.php b/app/Models/Extruder.php new file mode 100644 index 0000000..a32630d --- /dev/null +++ b/app/Models/Extruder.php @@ -0,0 +1,25 @@ +belongsTo(Manufacturer::class); + } + +} diff --git a/app/Models/Filament.php b/app/Models/Filament.php index a15f183..caf5dca 100644 --- a/app/Models/Filament.php +++ b/app/Models/Filament.php @@ -19,7 +19,13 @@ class Filament extends Model 'weight', 'diameter', 'price', - 'stock' + 'finish', + 'image', + 'stock', + 'temp_min', + 'temp_max', + 'buildplate_id', + 'extruder_id' ]; // Filament belongs to a type diff --git a/database/migrations/2025_03_10_151717_create_filament_types.php b/database/migrations/2025_03_10_151717_create_filament_types.php index ec48987..f03e714 100644 --- a/database/migrations/2025_03_10_151717_create_filament_types.php +++ b/database/migrations/2025_03_10_151717_create_filament_types.php @@ -13,9 +13,9 @@ return new class extends Migration { Schema::create('filament_types', function (Blueprint $table) { $table->id(); - $table->timestamps(); $table->string('name'); $table->string('description'); + $table->timestamps(); }); } diff --git a/database/migrations/2025_03_10_183844_create_colors.php b/database/migrations/2025_03_10_182844_create_colors.php similarity index 100% rename from database/migrations/2025_03_10_183844_create_colors.php rename to database/migrations/2025_03_10_182844_create_colors.php index 54ec1ef..f082cb1 100644 --- a/database/migrations/2025_03_10_183844_create_colors.php +++ b/database/migrations/2025_03_10_182844_create_colors.php @@ -13,9 +13,9 @@ return new class extends Migration { Schema::create('colors', function (Blueprint $table) { $table->id(); - $table->timestamps(); $table->string('name')->required(); $table->string('hex')->required(); + $table->timestamps(); }); } diff --git a/database/migrations/2025_03_10_183903_create_manufacturers.php b/database/migrations/2025_03_10_182903_create_manufacturers.php similarity index 92% rename from database/migrations/2025_03_10_183903_create_manufacturers.php rename to database/migrations/2025_03_10_182903_create_manufacturers.php index b99b372..73f94c6 100644 --- a/database/migrations/2025_03_10_183903_create_manufacturers.php +++ b/database/migrations/2025_03_10_182903_create_manufacturers.php @@ -13,12 +13,12 @@ return new class extends Migration { Schema::create('manufacturers', function (Blueprint $table) { $table->id(); - $table->timestamps(); $table->string('name')->required(); $table->string('description')->nullable(); $table->string('website')->nullable(); $table->string('logo')->nullable(); - + $table->integer('filament_count')->default(0); + $table->timestamps(); }); } diff --git a/database/migrations/2025_03_10_183058_create_filaments.php b/database/migrations/2025_03_10_183058_create_filaments.php index 2c6ca4c..1f7fdc5 100644 --- a/database/migrations/2025_03_10_183058_create_filaments.php +++ b/database/migrations/2025_03_10_183058_create_filaments.php @@ -13,15 +13,22 @@ return new class extends Migration { Schema::create('filaments', function (Blueprint $table) { $table->id(); - $table->timestamps(); $table->string('name')->required(); $table->string('description')->nullable(); - $table->string('color_id')->required(); - $table->string('manufacturer_id')->required(); - $table->string('type_id')->required(); + $table->foreignId('color_id')->constrained(); + $table->foreignId('manufacturer_id')->constrained(); + $table->foreignId('filament_type_id')->constrained(); $table->string('weight')->required(); $table->string('diameter')->required(); $table->string('price')->nullable(); + $table->string('finish')->nullable(); + $table->string('image')->nullable(); + $table->integer('stock')->default(0); + $table->integer('temp_min')->nullable(); + $table->integer('temp_max')->nullable(); + $table->integer('buildplate_id')->nullable(); + $table->integer('extruder_id')->nullable(); + $table->timestamps(); }); } diff --git a/database/migrations/2025_03_10_212629_add_filamentcout_to_manufacturers.php b/database/migrations/2025_03_10_212629_add_filamentcout_to_manufacturers.php deleted file mode 100644 index 270fe00..0000000 --- a/database/migrations/2025_03_10_212629_add_filamentcout_to_manufacturers.php +++ /dev/null @@ -1,30 +0,0 @@ -integer('filament_count')->default(0); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('manufacturers', function (Blueprint $table) { - // - $table->dropColumn('filament_count'); - }); - } -}; diff --git a/database/migrations/2025_03_15_185418_create_extruders_table.php b/database/migrations/2025_03_15_185418_create_extruders_table.php new file mode 100644 index 0000000..a2ce04e --- /dev/null +++ b/database/migrations/2025_03_15_185418_create_extruders_table.php @@ -0,0 +1,32 @@ +id(); + $table->string('name'); + $table->string('description')->nullable(); + $table->foreignId('manufacturer_id')->constrained(); + $table->string('diameter')->required(); + $table->string('temp_max')->required(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('extruders'); + } +}; diff --git a/database/migrations/2025_03_11_112017_add_filamentstock_to_filaments_table.php b/database/migrations/2025_03_15_185700_create_buildplates_table.php similarity index 50% rename from database/migrations/2025_03_11_112017_add_filamentstock_to_filaments_table.php rename to database/migrations/2025_03_15_185700_create_buildplates_table.php index 28ac742..378c344 100644 --- a/database/migrations/2025_03_11_112017_add_filamentstock_to_filaments_table.php +++ b/database/migrations/2025_03_15_185700_create_buildplates_table.php @@ -11,9 +11,13 @@ return new class extends Migration */ public function up(): void { - Schema::table('filaments', function (Blueprint $table) { - // adding stock to filaments table - $table->integer('stock')->default(0); + Schema::create('buildplates', function (Blueprint $table) { + $table->id(); + $table->string('name'); + $table->string('description'); + $table->foreignId('manufacturer_id')->constrained(); + $table->string('temp_max'); + $table->timestamps(); }); } @@ -22,9 +26,6 @@ return new class extends Migration */ public function down(): void { - Schema::table('filaments', function (Blueprint $table) { - // removing stock from filaments table - $table->dropColumn('stock'); - }); + Schema::dropIfExists('buildplates'); } }; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 9211282..dcf69a5 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -16,6 +16,13 @@ class DatabaseSeeder extends Seeder public function run(): void { User::factory(10)->create(); + + User::create([ + 'name' => 'Admin', + 'email' => 'admin@local', + 'password' => bcrypt('password') + ]); + $this ->call( ColorSeeder::class, ManufacturerSeeder::class