Merge branch 'feature/AddMachineAndRahdarToRoadPatrol' into 'develop'
Feature/add machine and rahdar to road patrol See merge request witelgroup/rms_v2!51
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
@@ -167,17 +168,23 @@ class RoadItemsProject extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function cmmsMachines(): BelongsToMany
|
||||
public function cmmsMachines(): MorphToMany
|
||||
{
|
||||
return $this->belongsToMany(CMMSMachine::class,
|
||||
'cmms_machine_road_items_project',
|
||||
'road_items_project_id',
|
||||
return $this->morphToMany(CMMSMachine::class,
|
||||
'machinable',
|
||||
'machinables',
|
||||
'machinable_id',
|
||||
'machine_id'
|
||||
);
|
||||
}
|
||||
|
||||
public function rahdaran(): BelongsToMany
|
||||
public function rahdaran(): MorphToMany
|
||||
{
|
||||
return $this->belongsToMany(Rahdaran::class,'rahdaran_road_items_project');
|
||||
return $this->morphToMany(Rahdaran::class,
|
||||
'rahdarable',
|
||||
'rahdarables',
|
||||
'rahdarable_id',
|
||||
'rahdar_id',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('machinables', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('machine_id')->constrained('cmms_machines')->noActionOnDelete();
|
||||
$table->morphs('machinable');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('machinable');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('rahdarables', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('rahdar_id')->constrained('rahdaran')->noActionOnDelete();
|
||||
$table->morphs('rahdarable');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('rahdarables');
|
||||
}
|
||||
};
|
||||
@@ -201,5 +201,6 @@ return [
|
||||
'fields.*.type' => 'نوع فیلد',
|
||||
'fields.*.option' => 'گزینه های فیلد',
|
||||
'cmms_machine_id' => 'کد یکتا ماشین',
|
||||
'contract_subitem_id' => 'کد یکتای پروژه',
|
||||
],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user