first change
This commit is contained in:
0
Modules/PMS/app/Models/.gitkeep
Normal file
0
Modules/PMS/app/Models/.gitkeep
Normal file
38
Modules/PMS/app/Models/Comment.php
Normal file
38
Modules/PMS/app/Models/Comment.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Comment extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = ['content', 'comment_by'];
|
||||
|
||||
// protected $casts = [
|
||||
// 'created_at' => 'datetime',
|
||||
// ];
|
||||
|
||||
protected function createdAtFormatted(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn($value, $attributes) => Carbon::parse($attributes['created_at'])->format('d, M Y H:i'),
|
||||
);
|
||||
}
|
||||
|
||||
public function comments()
|
||||
{
|
||||
return $this->morphMany(Comment::class, 'commentable');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'comment_by');
|
||||
}
|
||||
}
|
23
Modules/PMS/app/Models/KanbanColumn.php
Normal file
23
Modules/PMS/app/Models/KanbanColumn.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\PMS\Database\Factories\KanbanColumnFactory;
|
||||
|
||||
class KanbanColumn extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
public function tasks()
|
||||
{
|
||||
return $this->hasMany(Task::class,'status');
|
||||
}
|
||||
|
||||
}
|
42
Modules/PMS/app/Models/Project.php
Normal file
42
Modules/PMS/app/Models/Project.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Models;
|
||||
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use App\Traits\StatusTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Modules\Admin\Models\Department;
|
||||
use Modules\Employee\Models\Employee;
|
||||
|
||||
class Project extends Model
|
||||
{
|
||||
use StatusTrait, CreatedUpdatedBy;
|
||||
use \Staudenmeir\EloquentJsonRelations\HasJsonRelationships;
|
||||
protected $table = 'tbl_projects';
|
||||
protected $fillable = ['project_code', 'project_name', 'client_id', 'department_id', 'project_category_id', 'members_id', 'start_date', 'end_date', 'summary', 'key_notes', 'status', 'createdBy', 'updatedBy'];
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected $casts = [
|
||||
'members_id' => 'json',
|
||||
];
|
||||
const CATEGORY = [
|
||||
10 => 'Vue',
|
||||
11 => 'Laravel',
|
||||
];
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo(Client::class, 'client_id');
|
||||
}
|
||||
|
||||
public function projectCategory()
|
||||
{
|
||||
return $this->belongsTo(ProjectCategory::class, 'project_category_id');
|
||||
}
|
||||
|
||||
public function members()
|
||||
{
|
||||
return $this->belongsToJson(Employee::class, 'members_id->id');
|
||||
}
|
||||
|
||||
}
|
17
Modules/PMS/app/Models/ProjectCategory.php
Normal file
17
Modules/PMS/app/Models/ProjectCategory.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Models;
|
||||
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use App\Traits\StatusTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProjectCategory extends Model
|
||||
{
|
||||
use HasFactory, StatusTrait, CreatedUpdatedBy;
|
||||
|
||||
public $appends = ['status_name'];
|
||||
protected $table = 'tbl_project_categories';
|
||||
protected $fillable = ['title', 'desc'];
|
||||
}
|
117
Modules/PMS/app/Models/Task.php
Normal file
117
Modules/PMS/app/Models/Task.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Models;
|
||||
|
||||
use App\Models\Document;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Modules\Employee\Models\Employee;
|
||||
use Modules\Product\Models\Product;
|
||||
|
||||
class Task extends Model
|
||||
{
|
||||
use CreatedUpdatedBy;
|
||||
use \Staudenmeir\EloquentJsonRelations\HasJsonRelationships;
|
||||
|
||||
protected $table = 'tbl_tasks';
|
||||
protected $guarded = [];
|
||||
protected $appends = ['status_name', 'priority_status'];
|
||||
|
||||
// const CATEGORY = [
|
||||
// 10 => 'Vue',
|
||||
// 11 => 'Laravel',
|
||||
// ];
|
||||
|
||||
const PRIORITY = [
|
||||
10 => 'High',
|
||||
11 => 'Meduim',
|
||||
12 => 'Low',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'assigned_id' => 'json',
|
||||
];
|
||||
|
||||
protected function statusName(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: function (mixed $value, array $attributes) {
|
||||
$kanbanColumn = KanbanColumn::where('id',$attributes['status'])->first();
|
||||
return collect([
|
||||
'status' => $kanbanColumn->name ?? 'N/A',
|
||||
'color' => $kanbanColumn->name ?? '#808080'
|
||||
]);
|
||||
},
|
||||
|
||||
set: fn($value) => $value,
|
||||
);
|
||||
}
|
||||
|
||||
protected function priorityStatus(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: function (mixed $value, array $attributes) {
|
||||
switch ($attributes['priority']) {
|
||||
case '10':
|
||||
return '<span class="badge bg-danger">' . self::PRIORITY[$attributes['priority']] . '</span>';
|
||||
case '11':
|
||||
return '<span class="badge bg-info">' . self::PRIORITY[$attributes['priority']] . '</span>';
|
||||
case '12':
|
||||
return '<span class="badge bg-primary">' . self::PRIORITY[$attributes['priority']] . '</span>';
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
},
|
||||
set: fn($value) => $value,
|
||||
);
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class, 'product_id');
|
||||
}
|
||||
|
||||
public function subTask()
|
||||
{
|
||||
return $this->hasMany(Task::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function taskTime()
|
||||
{
|
||||
return $this->hasMany(TaskTime::class, 'task_id');
|
||||
}
|
||||
|
||||
public function latest_task_time()
|
||||
{
|
||||
return $this->hasOne(TaskTime::class, 'task_id')->latestOfMany();
|
||||
}
|
||||
|
||||
public function assignedUser()
|
||||
{
|
||||
return $this->belongsToJson(Employee::class, 'assigned_id->ids');
|
||||
}
|
||||
|
||||
public function taskCategory()
|
||||
{
|
||||
return $this->belongsTo(TaskCategory::class, 'task_category_id');
|
||||
}
|
||||
|
||||
public function documents(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
|
||||
public function comments()
|
||||
{
|
||||
return $this->morphMany(Comment::class, 'commentable');
|
||||
}
|
||||
|
||||
public function column()
|
||||
{
|
||||
return $this->belongsTo(KanbanColumn::class, 'status');
|
||||
}
|
||||
|
||||
}
|
25
Modules/PMS/app/Models/TaskCategory.php
Normal file
25
Modules/PMS/app/Models/TaskCategory.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\PMS\Database\Factories\TaskCategoryFactory;
|
||||
use App\Traits\StatusTrait;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
|
||||
class TaskCategory extends Model
|
||||
{
|
||||
use HasFactory, StatusTrait, CreatedUpdatedBy;
|
||||
|
||||
public $appends = ['status_name'];
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $table = 'tbl_task_categories';
|
||||
|
||||
protected $fillable = ['title', 'desc'];
|
||||
|
||||
}
|
20
Modules/PMS/app/Models/TaskTime.php
Normal file
20
Modules/PMS/app/Models/TaskTime.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TaskTime extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $table = 'tbl_task_times';
|
||||
protected $fillable = ['task_id', 'start_time', 'end_time'];
|
||||
|
||||
public function task()
|
||||
{
|
||||
return $this->belongsTo(Task::class, 'task_id');
|
||||
}
|
||||
}
|
140
Modules/PMS/app/Models/Ticket.php
Normal file
140
Modules/PMS/app/Models/Ticket.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Document;
|
||||
use Modules\Admin\Models\Department;
|
||||
use Modules\Employee\Models\Employee;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
class Ticket extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $table = 'tbl_tickets';
|
||||
// protected $fillable = ['subject', 'employee_id', 'department_id', 'assign_group_id', 'project_id', 'desc', 'file', 'ticket_type', 'status', 'priority'];
|
||||
protected $guarded = [];
|
||||
|
||||
protected $appends = ['status_name', 'priority_status', 'ticket_type'];
|
||||
|
||||
const STATUS = [
|
||||
10 => 'Pending',
|
||||
11 => 'Approved',
|
||||
12 => 'Rejected',
|
||||
];
|
||||
const PRIORITY = [
|
||||
10 => 'High',
|
||||
11 => 'Meduim',
|
||||
12 => 'Low',
|
||||
];
|
||||
|
||||
const TICKET_TYPE = [
|
||||
11 => 'Management',
|
||||
12 => 'Boxes',
|
||||
13 => 'Assets'
|
||||
];
|
||||
protected function statusName(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: function (mixed $value, array $attributes) {
|
||||
switch ($attributes['status']) {
|
||||
case '10':
|
||||
$color = 'danger';
|
||||
break;
|
||||
case '11':
|
||||
$color = 'info';
|
||||
break;
|
||||
case '12':
|
||||
$color = 'primary';
|
||||
break;
|
||||
case '13':
|
||||
$color = 'warning';
|
||||
break;
|
||||
case '14':
|
||||
$color = 'success';
|
||||
break;
|
||||
default:
|
||||
$color = 'light';
|
||||
break;
|
||||
}
|
||||
|
||||
return collect([
|
||||
'status' => self::STATUS[$attributes['status']],
|
||||
'color' => $color]);
|
||||
},
|
||||
set: fn($value) => $value,
|
||||
);
|
||||
}
|
||||
|
||||
protected function priorityStatus(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: function (mixed $value, array $attributes) {
|
||||
switch ($attributes['priority']) {
|
||||
case '10':
|
||||
return '<span class="badge bg-danger">' . self::PRIORITY[$attributes['priority']] . '</span>';
|
||||
break;
|
||||
case '11':
|
||||
return '<span class="badge bg-info">' . self::PRIORITY[$attributes['priority']] . '</span>';
|
||||
break;
|
||||
case '12':
|
||||
return '<span class="badge bg-primary">' . self::PRIORITY[$attributes['priority']] . '</span>';
|
||||
break;
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
},
|
||||
set: fn($value) => $value,
|
||||
);
|
||||
}
|
||||
|
||||
protected function ticketType(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: function (mixed $value, array $attributes) {
|
||||
switch ($attributes['ticket_type']) {
|
||||
case '11':
|
||||
return '<span class="badge bg-info">' . self::TICKET_TYPE[$attributes['ticket_type']] . '</span>';
|
||||
break;
|
||||
case '12':
|
||||
return '<span class="badge bg-info">' . self::TICKET_TYPE[$attributes['ticket_type']] . '</span>';
|
||||
break;
|
||||
case '13':
|
||||
return '<span class="badge bg-info">' . self::TICKET_TYPE[$attributes['ticket_type']] . '</span>';
|
||||
break;
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
},
|
||||
set: fn($value) => $value,
|
||||
);
|
||||
}
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo(Project::class, 'project_id');
|
||||
}
|
||||
|
||||
public function employee()
|
||||
{
|
||||
return $this->belongsTo(Employee::class, 'employee_id');
|
||||
}
|
||||
public function department()
|
||||
{
|
||||
return $this->belongsTo(Department::class, 'department_id')->withDefault();
|
||||
}
|
||||
public function documents(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
|
||||
public function comments()
|
||||
{
|
||||
return $this->morphMany(Comment::class, 'commentable');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user