Changes 0128092025
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class FieldJob extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'field_job_setting_id',
|
||||
'asigned_user_id',
|
||||
'start_date',
|
||||
'end_date',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
];
|
||||
|
||||
protected static function booted(){
|
||||
static::creating(function (FieldJob $fieldJob) {
|
||||
if(!isset($fieldJob->user_id)){
|
||||
$fieldJob->user_id = auth()->id();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function setting(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(FieldJobSetting::class, 'field_job_setting_id');
|
||||
}
|
||||
|
||||
public function assignedUser(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'asigned_user_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class FieldJobSetting extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'segment_id',
|
||||
'asign_decision_id',
|
||||
'complete_decision_id',
|
||||
];
|
||||
|
||||
public function segment(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Segment::class);
|
||||
}
|
||||
|
||||
public function asignDecision(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Decision::class, 'asign_decision_id');
|
||||
}
|
||||
|
||||
public function completeDecision(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Decision::class, 'complete_decision_id');
|
||||
}
|
||||
|
||||
public function fieldJobs(): HasMany
|
||||
{
|
||||
return $this->hasMany(FieldJob::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user