ranjith-dev #48

Merged
jothi merged 2 commits from ranjith-dev into master 2025-12-23 05:50:34 +00:00
2 changed files with 56 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
class StickerStructureDetail extends Model class StickerStructureDetail extends Model
@@ -11,6 +12,8 @@ class StickerStructureDetail extends Model
use SoftDeletes; use SoftDeletes;
protected $fillable = [ protected $fillable = [
'plant_id',
'item_characteristic_id',
'sticker_id', 'sticker_id',
'sticker_width', 'sticker_width',
'sticker_height', 'sticker_height',
@@ -23,4 +26,15 @@ class StickerStructureDetail extends Model
'created_by', 'created_by',
'updated_by' 'updated_by'
]; ];
public function plant(): BelongsTo
{
return $this->belongsTo(Plant::class);
}
public function itemCharacteristic(): BelongsTo
{
return $this->belongsTo(ItemCharacteristic::class, 'item_characteristic_id');
}
} }

View File

@@ -0,0 +1,42 @@
<?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
{
$sql1 = <<<'SQL'
ALTER TABLE sticker_structure_details
ADD COLUMN plant_id BIGINT NOT NULL,
ADD CONSTRAINT sticker_structure_details_plant_id_fkey
FOREIGN KEY (plant_id) REFERENCES plants(id);
SQL;
DB::statement($sql1);
$sql2 = <<<'SQL'
ALTER TABLE sticker_structure_details
ADD COLUMN item_characteristic_id BIGINT NULL,
ADD CONSTRAINT sticker_structure_details_item_characteristic_id_fkey
FOREIGN KEY (item_characteristic_id) REFERENCES item_characteristics(id);
SQL;
DB::statement($sql2);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('sticker_structure_details', function (Blueprint $table) {
// //
// });
}
};