Merge branch 'laravel-12' of http://gitlab.aridia.nl/iridium34/FilamentLaravel into laravel-12
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Buildplate extends Model
|
||||||
|
{
|
||||||
|
// Buildplate Model
|
||||||
|
protected $table = 'buildplates';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'description',
|
||||||
|
'manufacturer_id',
|
||||||
|
'temp_max'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function filament()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Filament::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function manufacturer()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Manufacturer::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Extruder extends Model
|
||||||
|
{
|
||||||
|
// Extruder Model
|
||||||
|
protected $table = 'extruders';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'description',
|
||||||
|
'manufacturer_id',
|
||||||
|
'diameter',
|
||||||
|
'temp_max'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function manufacturer()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Manufacturer::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,7 +19,13 @@ class Filament extends Model
|
|||||||
'weight',
|
'weight',
|
||||||
'diameter',
|
'diameter',
|
||||||
'price',
|
'price',
|
||||||
'stock'
|
'finish',
|
||||||
|
'image',
|
||||||
|
'stock',
|
||||||
|
'temp_min',
|
||||||
|
'temp_max',
|
||||||
|
'buildplate_id',
|
||||||
|
'extruder_id'
|
||||||
];
|
];
|
||||||
|
|
||||||
// Filament belongs to a type
|
// Filament belongs to a type
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('filament_types', function (Blueprint $table) {
|
Schema::create('filament_types', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->timestamps();
|
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->string('description');
|
$table->string('description');
|
||||||
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -13,9 +13,9 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('colors', function (Blueprint $table) {
|
Schema::create('colors', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->timestamps();
|
|
||||||
$table->string('name')->required();
|
$table->string('name')->required();
|
||||||
$table->string('hex')->required();
|
$table->string('hex')->required();
|
||||||
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
+2
-2
@@ -13,12 +13,12 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('manufacturers', function (Blueprint $table) {
|
Schema::create('manufacturers', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->timestamps();
|
|
||||||
$table->string('name')->required();
|
$table->string('name')->required();
|
||||||
$table->string('description')->nullable();
|
$table->string('description')->nullable();
|
||||||
$table->string('website')->nullable();
|
$table->string('website')->nullable();
|
||||||
$table->string('logo')->nullable();
|
$table->string('logo')->nullable();
|
||||||
|
$table->integer('filament_count')->default(0);
|
||||||
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,15 +13,22 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('filaments', function (Blueprint $table) {
|
Schema::create('filaments', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->timestamps();
|
|
||||||
$table->string('name')->required();
|
$table->string('name')->required();
|
||||||
$table->string('description')->nullable();
|
$table->string('description')->nullable();
|
||||||
$table->string('color_id')->required();
|
$table->foreignId('color_id')->constrained();
|
||||||
$table->string('manufacturer_id')->required();
|
$table->foreignId('manufacturer_id')->constrained();
|
||||||
$table->string('type_id')->required();
|
$table->foreignId('filament_type_id')->constrained();
|
||||||
$table->string('weight')->required();
|
$table->string('weight')->required();
|
||||||
$table->string('diameter')->required();
|
$table->string('diameter')->required();
|
||||||
$table->string('price')->nullable();
|
$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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
<?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::table('manufacturers', function (Blueprint $table) {
|
|
||||||
//
|
|
||||||
$table->integer('filament_count')->default(0);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::table('manufacturers', function (Blueprint $table) {
|
|
||||||
//
|
|
||||||
$table->dropColumn('filament_count');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -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.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('extruders', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
};
|
||||||
+8
-7
@@ -11,9 +11,13 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Schema::table('filaments', function (Blueprint $table) {
|
Schema::create('buildplates', function (Blueprint $table) {
|
||||||
// adding stock to filaments table
|
$table->id();
|
||||||
$table->integer('stock')->default(0);
|
$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
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::table('filaments', function (Blueprint $table) {
|
Schema::dropIfExists('buildplates');
|
||||||
// removing stock from filaments table
|
|
||||||
$table->dropColumn('stock');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -13,7 +13,7 @@ class ColorSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
// Seed Random Colors
|
// Seed predefined Colors
|
||||||
$colors = [
|
$colors = [
|
||||||
['name' => 'Red', 'hex' => '#FF0000'],
|
['name' => 'Red', 'hex' => '#FF0000'],
|
||||||
['name' => 'Green', 'hex' => '#00FF00'],
|
['name' => 'Green', 'hex' => '#00FF00'],
|
||||||
@@ -28,26 +28,11 @@ class ColorSeeder extends Seeder
|
|||||||
['name' => 'White', 'hex' => '#FFFFFF'],
|
['name' => 'White', 'hex' => '#FFFFFF'],
|
||||||
['name' => 'Gold', 'hex' => '#FFD700'],
|
['name' => 'Gold', 'hex' => '#FFD700'],
|
||||||
['name' => 'Silver', 'hex' => '#C0C0C0'],
|
['name' => 'Silver', 'hex' => '#C0C0C0'],
|
||||||
['name' => 'Cyan', 'hex' => '#00FFFF'],
|
['name' => 'Cyan', 'hex' => '#00FFFF']
|
||||||
['name' => 'Magenta', 'hex' => '#FF00FF'],
|
|
||||||
['name' => 'Lime', 'hex' => '#00FF00'],
|
|
||||||
['name' => 'Olive', 'hex' => '#808000'],
|
|
||||||
['name' => 'Teal', 'hex' => '#008080'],
|
|
||||||
['name' => 'Maroon', 'hex' => '#800000'],
|
|
||||||
['name' => 'Navy', 'hex' => '#000080'],
|
|
||||||
['name' => 'Aqua', 'hex' => '#00FFFF'],
|
|
||||||
['name' => 'Lavender', 'hex' => '#E6E6FA'],
|
|
||||||
['name' => 'Turquoise', 'hex' => '#40E0D0'],
|
|
||||||
['name' => 'Fuchsia', 'hex' => '#FF00FF'],
|
|
||||||
['name' => 'Indigo', 'hex' => '#4B0082'],
|
|
||||||
['name' => 'Crimson', 'hex' => '#DC143C'],
|
|
||||||
['name' => 'Plum', 'hex' => '#DDA0DD']
|
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($colors as $color) {
|
foreach ($colors as $color) {
|
||||||
Color::create($color);
|
Color::create($color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ namespace Database\Seeders;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Database\Seeders\ColorSeeder;
|
||||||
|
use Database\Seeders\ManufacturerSeeder;
|
||||||
|
|
||||||
class DatabaseSeeder extends Seeder
|
class DatabaseSeeder extends Seeder
|
||||||
{
|
{
|
||||||
@@ -15,5 +17,17 @@ class DatabaseSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
User::factory(10)->create();
|
User::factory(10)->create();
|
||||||
|
|
||||||
|
User::create([
|
||||||
|
'name' => 'Admin',
|
||||||
|
'email' => 'admin@local',
|
||||||
|
'password' => bcrypt('password')
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this ->call(
|
||||||
|
ColorSeeder::class,
|
||||||
|
ManufacturerSeeder::class
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ namespace Database\Seeders;
|
|||||||
|
|
||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
use App\Models\Manufacturer;
|
use App\Models\Manufacturer;
|
||||||
|
|
||||||
class ManufacturerSeeder extends Seeder
|
class ManufacturerSeeder extends Seeder
|
||||||
@@ -16,16 +13,15 @@ class ManufacturerSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
// Seed Random Manufacturers
|
// Create predefined Manufacturers
|
||||||
for ($i = 0; $i < 10; $i++) {
|
$manufacturers = [
|
||||||
DB::table('manufacturers')->insert([
|
['name' => 'Bambulab', 'description' => 'Bambulab is a manufacturer of high quality products.', 'website' => 'https://bambulab.com', 'logo' => 'https://example.com/bambulab-logo.png']
|
||||||
'name' => Str::random(10),
|
|
||||||
'description' => Str::random(40),
|
];
|
||||||
'website' => Str::random(10).'.com'
|
|
||||||
]);
|
foreach ($manufacturers as $manufacturer) {
|
||||||
|
Manufacturer::create($manufacturer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user