first commit
This commit is contained in:
0
Modules/PMS/app/Models/.gitkeep
Normal file
0
Modules/PMS/app/Models/.gitkeep
Normal file
21
Modules/PMS/app/Models/Client.php
Normal file
21
Modules/PMS/app/Models/Client.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Models;
|
||||
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use App\Traits\StatusTrait;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Client extends Model
|
||||
{
|
||||
use StatusTrait, CreatedUpdatedBy;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $table = 'tbl_clients';
|
||||
protected $guarded = [];
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
}
|
36
Modules/PMS/app/Models/Project.php
Normal file
36
Modules/PMS/app/Models/Project.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Models;
|
||||
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use App\Traits\StatusTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Modules\Employee\Models\Employee;
|
||||
|
||||
class Project extends Model
|
||||
{
|
||||
use StatusTrait, CreatedUpdatedBy;
|
||||
|
||||
protected $table = 'tbl_projects';
|
||||
protected $fillable = ['project_code', 'project_name', 'client_id', 'project_category_id', 'members_id', 'start_date', 'end_date', 'summary', 'status', 'createdBy', 'updatedBy', 'created_at', 'updated_at'];
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected $casts = [
|
||||
'members_id' => 'array',
|
||||
];
|
||||
const CATEGORY = [
|
||||
10 => 'Vue',
|
||||
11 => 'Laravel',
|
||||
];
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo(Client::class, 'client_id');
|
||||
}
|
||||
|
||||
public function members()
|
||||
{
|
||||
return Employee::whereIn('id', $this->members_id)->get();
|
||||
}
|
||||
|
||||
}
|
112
Modules/PMS/app/Models/Task.php
Normal file
112
Modules/PMS/app/Models/Task.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Models;
|
||||
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Modules\Employee\Models\Employee;
|
||||
|
||||
class Task extends Model
|
||||
{
|
||||
use CreatedUpdatedBy;
|
||||
|
||||
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',
|
||||
];
|
||||
|
||||
const STATUS = [
|
||||
10 => 'Incomplete',
|
||||
11 => 'To DO',
|
||||
12 => 'Doing',
|
||||
13 => 'In Review',
|
||||
14 => 'Completed',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'assigned_id' => 'array',
|
||||
];
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo(Project::class, 'project_id');
|
||||
}
|
||||
|
||||
public function assigned()
|
||||
{
|
||||
return $this->belongsTo(Employee::class, 'assigned_id');
|
||||
}
|
||||
|
||||
public function taskCategory()
|
||||
{
|
||||
return self::CATEGORY[$this->task_category_id ?? null];
|
||||
}
|
||||
|
||||
}
|
33
Modules/PMS/app/Models/Ticket.php
Normal file
33
Modules/PMS/app/Models/Ticket.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Modules\Employee\Models\Employee;
|
||||
|
||||
class Ticket extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $table = 'tbl_tickets';
|
||||
protected $fillable = ['subject', 'employee_id', 'assign_group_id', 'project_id', 'desc', 'file', 'ticket_type', 'status'];
|
||||
|
||||
const STATUS = [
|
||||
1 => 'Pending',
|
||||
2 => 'Approved',
|
||||
3 => 'Rejected',
|
||||
];
|
||||
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo(Project::class, 'project_id');
|
||||
}
|
||||
|
||||
public function employee()
|
||||
{
|
||||
return $this->belongsTo(Employee::class, 'employee_id');
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user