Merge branch 'DBextention' into 'laravel-12'
Dbextention See merge request iridium34/FilamentLaravel!5
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',
|
||||
'diameter',
|
||||
'price',
|
||||
'stock'
|
||||
'finish',
|
||||
'image',
|
||||
'stock',
|
||||
'temp_min',
|
||||
'temp_max',
|
||||
'buildplate_id',
|
||||
'extruder_id'
|
||||
];
|
||||
|
||||
// Filament belongs to a type
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
+2
-2
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
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');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user