Compare commits
2 Commits
8662e092df
...
43e8a70f9c
| Author | SHA1 | Date | |
|---|---|---|---|
| 43e8a70f9c | |||
| ca74a0c2e2 |
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
|
|
||||||
class InspectionTemplate extends Model
|
class InspectionTemplate extends Model
|
||||||
{
|
{
|
||||||
protected $fillable = ['name', 'description', 'project_id', 'fields'];
|
protected $fillable = ['name', 'description', 'project_id', 'phase_id', 'fields'];
|
||||||
|
|
||||||
protected $casts = ['fields' => 'array'];
|
protected $casts = ['fields' => 'array'];
|
||||||
|
|
||||||
@@ -15,6 +15,11 @@ class InspectionTemplate extends Model
|
|||||||
return $this->belongsTo(Project::class);
|
return $this->belongsTo(Project::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function phase()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Phase::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function inspections()
|
public function inspections()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Inspection::class);
|
return $this->hasMany(Inspection::class);
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?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('inspection_templates', function (Blueprint $table) {
|
||||||
|
$table->foreignId('phase_id')->nullable()->constrained('phases')->onDelete('set null');
|
||||||
|
$table->index('phase_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('inspection_templates', function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['phase_id']);
|
||||||
|
$table->dropColumn('phase_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user