create mission tables with factory and seeder
This commit is contained in:
29
app/Models/Mission.php
Normal file
29
app/Models/Mission.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
|
||||
class Mission extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function roadItems(): MorphToMany
|
||||
{
|
||||
return $this->morphedByMany(RoadItemsProject::class, 'missionable');
|
||||
}
|
||||
|
||||
public function roadPatrols(): MorphToMany
|
||||
{
|
||||
return $this->morphedByMany(RoadPatrol::class, 'missionable');
|
||||
}
|
||||
|
||||
public function roadObserveds(): MorphToMany
|
||||
{
|
||||
return $this->morphedByMany(RoadObserved::class, 'missionable');
|
||||
}
|
||||
}
|
||||
13
app/Models/MissionHistory.php
Normal file
13
app/Models/MissionHistory.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MissionHistory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
}
|
||||
11
app/Models/MissionState.php
Normal file
11
app/Models/MissionState.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MissionState extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -187,4 +187,14 @@ class RoadItemsProject extends Model
|
||||
'rahdar_id',
|
||||
);
|
||||
}
|
||||
|
||||
public function missions(): MorphToMany
|
||||
{
|
||||
return $this->morphToMany(Mission::class,
|
||||
'missionable',
|
||||
'missionables',
|
||||
'missionable_id',
|
||||
'mission_id',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class RoadObserved extends Model
|
||||
@@ -124,4 +125,14 @@ class RoadObserved extends Model
|
||||
: Storage::disk('public')->url($value))
|
||||
);
|
||||
}
|
||||
|
||||
public function missions(): MorphToMany
|
||||
{
|
||||
return $this->morphToMany(Mission::class,
|
||||
'missionable',
|
||||
'missionables',
|
||||
'missionable_id',
|
||||
'mission_id',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,4 +45,14 @@ class RoadPatrol extends Model
|
||||
'rahdar_id',
|
||||
);
|
||||
}
|
||||
|
||||
public function missions(): MorphToMany
|
||||
{
|
||||
return $this->morphToMany(Mission::class,
|
||||
'missionable',
|
||||
'missionables',
|
||||
'missionable_id',
|
||||
'mission_id',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user