add mutator for mission
This commit is contained in:
@@ -14,7 +14,7 @@ enum MissionStates: int
|
|||||||
public static function name(int $state): string
|
public static function name(int $state): string
|
||||||
{
|
{
|
||||||
$mapArray = [
|
$mapArray = [
|
||||||
1 => 'درخواست ایجاد شد و در حال بررسی در توسط واحد نقلیه است',
|
1 => 'درخواست ایجاد شد و در حال بررسی توسط واحد نقلیه است',
|
||||||
2 => 'خودرو اختصاص داده شد و درخواست توسط واحد کنترل در حال بررسی است',
|
2 => 'خودرو اختصاص داده شد و درخواست توسط واحد کنترل در حال بررسی است',
|
||||||
3 => 'درخواست توسط واحد کنترل تایید شد و ماموریت آغاز می شود',
|
3 => 'درخواست توسط واحد کنترل تایید شد و ماموریت آغاز می شود',
|
||||||
4 => 'اتمام ماموریت',
|
4 => 'اتمام ماموریت',
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class RequestPortalController extends Controller
|
|||||||
'edare_shahri_name'=> $user->edare_shahri_name ?? null,
|
'edare_shahri_name'=> $user->edare_shahri_name ?? null,
|
||||||
'state_id' =>$state,
|
'state_id' =>$state,
|
||||||
'state_name' => MissionStates::name($state),
|
'state_name' => MissionStates::name($state),
|
||||||
'requested_machines' => $request->requested_machines,
|
'requested_machines' => json_encode($request->requested_machines),
|
||||||
'type' => $request->type,
|
'type' => $request->type,
|
||||||
'start_date' => $request->start_date,
|
'start_date' => $request->start_date,
|
||||||
'end_date' => $request->end_date,
|
'end_date' => $request->end_date,
|
||||||
@@ -63,7 +63,7 @@ class RequestPortalController extends Controller
|
|||||||
$mission->update([
|
$mission->update([
|
||||||
'state_id' =>$state,
|
'state_id' =>$state,
|
||||||
'state_name' => MissionStates::name($state),
|
'state_name' => MissionStates::name($state),
|
||||||
'requested_machines' => $request->requested_machines,
|
'requested_machines' => json_encode($request->requested_machines),
|
||||||
'type' => $request->type,
|
'type' => $request->type,
|
||||||
'start_date' => $request->start_date,
|
'start_date' => $request->start_date,
|
||||||
'end_date' => $request->end_date,
|
'end_date' => $request->end_date,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||||
@@ -12,6 +13,13 @@ class Mission extends Model
|
|||||||
|
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
|
protected function requestedMachines(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn ($value) => json_decode($value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function roadItems(): MorphToMany
|
public function roadItems(): MorphToMany
|
||||||
{
|
{
|
||||||
return $this->morphedByMany(RoadItemsProject::class, 'missionable');
|
return $this->morphedByMany(RoadItemsProject::class, 'missionable');
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ return new class extends Migration
|
|||||||
$table->string('province_name');
|
$table->string('province_name');
|
||||||
$table->unsignedBigInteger('edare_shahri_id')->nullable();
|
$table->unsignedBigInteger('edare_shahri_id')->nullable();
|
||||||
$table->foreign('edare_shahri_id')->references('id')->on('edarate_shahri')->noActionOnDelete();
|
$table->foreign('edare_shahri_id')->references('id')->on('edarate_shahri')->noActionOnDelete();
|
||||||
$table->string('edare_shahri_name');
|
$table->string('edare_shahri_name')->nullable();
|
||||||
$table->json('requested_machines');
|
$table->json('requested_machines');
|
||||||
$table->string('type');
|
$table->string('type');
|
||||||
$table->dateTime('start_date');
|
$table->dateTime('start_date');
|
||||||
|
|||||||
Reference in New Issue
Block a user