feat: Initialize core application structure including authentication, role-based dashboards, service task management, and integration workflows.
This commit is contained in:
36
app/Models/Agent.php
Normal file
36
app/Models/Agent.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Agent extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email',
|
||||
'position',
|
||||
'department',
|
||||
'arrival_date',
|
||||
'integration_status',
|
||||
'created_by',
|
||||
'validated_by_rh_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'arrival_date' => 'date',
|
||||
'integration_status' => \App\Enums\IntegrationStatus::class,
|
||||
'validated_by_rh_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function creator()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function integrationRequests()
|
||||
{
|
||||
return $this->hasMany(IntegrationRequest::class);
|
||||
}
|
||||
}
|
||||
22
app/Models/Attachment.php
Normal file
22
app/Models/Attachment.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Attachment extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'service_task_id',
|
||||
'filename',
|
||||
'original_name',
|
||||
'path',
|
||||
'mime_type',
|
||||
'size'
|
||||
];
|
||||
|
||||
public function serviceTask()
|
||||
{
|
||||
return $this->belongsTo(ServiceTask::class);
|
||||
}
|
||||
}
|
||||
20
app/Models/Comment.php
Normal file
20
app/Models/Comment.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Comment extends Model
|
||||
{
|
||||
protected $fillable = ['user_id', 'content', 'commentable_id', 'commentable_type'];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function commentable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
}
|
||||
69
app/Models/IntegrationRequest.php
Normal file
69
app/Models/IntegrationRequest.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
|
||||
class IntegrationRequest extends Model
|
||||
{
|
||||
use LogsActivity;
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly(['status', 'type', 'completed_at'])
|
||||
->logOnlyDirty()
|
||||
->dontSubmitEmptyLogs();
|
||||
}
|
||||
|
||||
public function state(): \App\States\Integration\IntegrationState
|
||||
{
|
||||
return match ($this->status) {
|
||||
\App\Enums\IntegrationStatus::Draft => new \App\States\Integration\DraftState($this),
|
||||
\App\Enums\IntegrationStatus::PendingRHValidation => new \App\States\Integration\PendingRHValidationState($this),
|
||||
\App\Enums\IntegrationStatus::InProgress => new \App\States\Integration\InProgressState($this),
|
||||
\App\Enums\IntegrationStatus::WaitingServices => new \App\States\Integration\WaitingServicesState($this),
|
||||
\App\Enums\IntegrationStatus::Completed => new \App\States\Integration\CompletedState($this),
|
||||
\App\Enums\IntegrationStatus::Cancelled => new \App\States\Integration\CancelledState($this),
|
||||
\App\Enums\IntegrationStatus::Rejected => new \App\States\Integration\RejectedState($this),
|
||||
default => throw new \Exception("Unknown state: {$this->status->value}"),
|
||||
};
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'agent_id',
|
||||
'template_id',
|
||||
'status',
|
||||
'type',
|
||||
'global_deadline',
|
||||
'completed_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'status' => \App\Enums\IntegrationStatus::class,
|
||||
'global_deadline' => 'date',
|
||||
'completed_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function agent()
|
||||
{
|
||||
return $this->belongsTo(Agent::class);
|
||||
}
|
||||
|
||||
public function template()
|
||||
{
|
||||
return $this->belongsTo(IntegrationTemplate::class);
|
||||
}
|
||||
|
||||
public function serviceTasks()
|
||||
{
|
||||
return $this->hasMany(ServiceTask::class);
|
||||
}
|
||||
|
||||
public function comments()
|
||||
{
|
||||
return $this->morphMany(Comment::class, 'commentable');
|
||||
}
|
||||
}
|
||||
19
app/Models/IntegrationTemplate.php
Normal file
19
app/Models/IntegrationTemplate.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class IntegrationTemplate extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
public function serviceItems()
|
||||
{
|
||||
return $this->hasMany(TemplateServiceItem::class, 'template_id');
|
||||
}
|
||||
}
|
||||
19
app/Models/Service.php
Normal file
19
app/Models/Service.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Service extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'code',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
public function serviceTasks()
|
||||
{
|
||||
return $this->hasMany(ServiceTask::class);
|
||||
}
|
||||
}
|
||||
79
app/Models/ServiceTask.php
Normal file
79
app/Models/ServiceTask.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
|
||||
class ServiceTask extends Model
|
||||
{
|
||||
use LogsActivity;
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly(['status', 'completed_at', 'validated_by'])
|
||||
->logOnlyDirty()
|
||||
->dontSubmitEmptyLogs();
|
||||
}
|
||||
|
||||
public function state(): \App\States\ServiceTask\ServiceTaskState
|
||||
{
|
||||
return match ($this->status) {
|
||||
\App\Enums\ServiceTaskStatus::Pending => new \App\States\ServiceTask\PendingState($this),
|
||||
\App\Enums\ServiceTaskStatus::InProgress => new \App\States\ServiceTask\InProgressState($this),
|
||||
\App\Enums\ServiceTaskStatus::WaitingValidation => new \App\States\ServiceTask\WaitingValidationState($this),
|
||||
\App\Enums\ServiceTaskStatus::Completed => new \App\States\ServiceTask\CompletedState($this),
|
||||
\App\Enums\ServiceTaskStatus::Rejected => new \App\States\ServiceTask\RejectedState($this),
|
||||
default => throw new \Exception("Unknown state: {$this->status->value}"),
|
||||
};
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'integration_request_id',
|
||||
'service_id',
|
||||
'status',
|
||||
'sla_deadline',
|
||||
'started_at',
|
||||
'completed_at',
|
||||
'validated_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'status' => \App\Enums\ServiceTaskStatus::class,
|
||||
'sla_deadline' => 'datetime',
|
||||
'started_at' => 'datetime',
|
||||
'completed_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function integrationRequest()
|
||||
{
|
||||
return $this->belongsTo(IntegrationRequest::class);
|
||||
}
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
public function validator()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'validated_by');
|
||||
}
|
||||
|
||||
public function taskItems()
|
||||
{
|
||||
return $this->hasMany(TaskItem::class);
|
||||
}
|
||||
|
||||
public function comments()
|
||||
{
|
||||
return $this->morphMany(Comment::class, 'commentable');
|
||||
}
|
||||
|
||||
public function attachments()
|
||||
{
|
||||
return $this->hasMany(Attachment::class);
|
||||
}
|
||||
}
|
||||
37
app/Models/TaskItem.php
Normal file
37
app/Models/TaskItem.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TaskItem extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'service_task_id',
|
||||
'label',
|
||||
'is_mandatory',
|
||||
'is_completed',
|
||||
'completed_at',
|
||||
'completed_by',
|
||||
'data',
|
||||
'fields_definition',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_mandatory' => 'boolean',
|
||||
'is_completed' => 'boolean',
|
||||
'completed_at' => 'datetime',
|
||||
'data' => 'array',
|
||||
'fields_definition' => 'array',
|
||||
];
|
||||
|
||||
public function serviceTask()
|
||||
{
|
||||
return $this->belongsTo(ServiceTask::class);
|
||||
}
|
||||
|
||||
public function completedBy()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'completed_by');
|
||||
}
|
||||
}
|
||||
31
app/Models/TemplateServiceItem.php
Normal file
31
app/Models/TemplateServiceItem.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TemplateServiceItem extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'template_id',
|
||||
'service_id',
|
||||
'label',
|
||||
'is_mandatory',
|
||||
'fields',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_mandatory' => 'boolean',
|
||||
'fields' => 'array',
|
||||
];
|
||||
|
||||
public function template()
|
||||
{
|
||||
return $this->belongsTo(IntegrationTemplate::class);
|
||||
}
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
}
|
||||
50
app/Models/User.php
Normal file
50
app/Models/User.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable, HasRoles;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user