first change
This commit is contained in:
0
Modules/PMS/app/Repositories/.gitkeep
Normal file
0
Modules/PMS/app/Repositories/.gitkeep
Normal file
14
Modules/PMS/app/Repositories/KanbanColumnInterface.php
Normal file
14
Modules/PMS/app/Repositories/KanbanColumnInterface.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
|
||||
interface KanbanColumnInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getKanbanColumnById($clientId);
|
||||
public function delete($clientId);
|
||||
public function create($clientDetails);
|
||||
public function update($clientId, array $newDetails);
|
||||
public function pluck(callable $query = null);
|
||||
|
||||
}
|
43
Modules/PMS/app/Repositories/KanbanColumnRepository.php
Normal file
43
Modules/PMS/app/Repositories/KanbanColumnRepository.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
|
||||
use Modules\PMS\Models\KanbanColumn;
|
||||
|
||||
class KanbanColumnRepository implements KanbanColumnInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return KanbanColumn::orderBy('position')->get();
|
||||
}
|
||||
|
||||
public function getKanbanColumnById($TaskCategoryId)
|
||||
{
|
||||
return KanbanColumn::findOrFail($TaskCategoryId);
|
||||
}
|
||||
|
||||
public function delete($TaskCategoryId)
|
||||
{
|
||||
KanbanColumn::destroy($TaskCategoryId);
|
||||
}
|
||||
|
||||
public function create($TaskCategoryDetails)
|
||||
{
|
||||
return KanbanColumn::create($TaskCategoryDetails);
|
||||
}
|
||||
|
||||
public function update($TaskCategoryId, array $newDetails)
|
||||
{
|
||||
return KanbanColumn::whereId($TaskCategoryId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck(callable $query = null)
|
||||
{
|
||||
$baseQuery = KanbanColumn::query();
|
||||
if (is_callable($query)) {
|
||||
$query($baseQuery);
|
||||
}
|
||||
|
||||
return $baseQuery->pluck('name', 'id')->all();
|
||||
}
|
||||
}
|
14
Modules/PMS/app/Repositories/TaskCategoryInterface.php
Normal file
14
Modules/PMS/app/Repositories/TaskCategoryInterface.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
|
||||
interface TaskCategoryInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getTaskCategoryById($clientId);
|
||||
public function delete($clientId);
|
||||
public function create($clientDetails);
|
||||
public function update($clientId, array $newDetails);
|
||||
public function pluck();
|
||||
|
||||
}
|
37
Modules/PMS/app/Repositories/TaskCategoryRepository.php
Normal file
37
Modules/PMS/app/Repositories/TaskCategoryRepository.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
|
||||
use Modules\PMS\Models\TaskCategory;
|
||||
|
||||
class TaskCategoryRepository implements TaskCategoryInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return TaskCategory::get();
|
||||
}
|
||||
|
||||
public function getTaskCategoryById($TaskCategoryId)
|
||||
{
|
||||
return TaskCategory::findOrFail($TaskCategoryId);
|
||||
}
|
||||
|
||||
public function delete($TaskCategoryId)
|
||||
{
|
||||
TaskCategory::destroy($TaskCategoryId);
|
||||
}
|
||||
|
||||
public function create($TaskCategoryDetails)
|
||||
{
|
||||
return TaskCategory::create($TaskCategoryDetails);
|
||||
}
|
||||
|
||||
public function update($TaskCategoryId, array $newDetails)
|
||||
{
|
||||
return TaskCategory::whereId($TaskCategoryId)->update($newDetails);
|
||||
}
|
||||
public function pluck()
|
||||
{
|
||||
return TaskCategory::pluck('title', 'id');
|
||||
}
|
||||
}
|
19
Modules/PMS/app/Repositories/TaskInterface.php
Normal file
19
Modules/PMS/app/Repositories/TaskInterface.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
|
||||
interface TaskInterface
|
||||
{
|
||||
public function findAll($filters = [], $limit = null, $offset = null);
|
||||
public function getTaskById($clientId);
|
||||
public function delete($clientId);
|
||||
public function create($clientDetails);
|
||||
public function update($clientId, array $newDetails);
|
||||
public function pluck();
|
||||
public function getAllTasks($filters = []);
|
||||
public function findAllWithRelations(array $relations = [], $limit = null);
|
||||
public function getTaskCountsByCategory($userId = null);
|
||||
|
||||
|
||||
// public function getTaskbyMembers($employee_id);
|
||||
}
|
116
Modules/PMS/app/Repositories/TaskRepository.php
Normal file
116
Modules/PMS/app/Repositories/TaskRepository.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\PMS\Models\KanbanColumn;
|
||||
use Modules\PMS\Models\Task;
|
||||
|
||||
class TaskRepository implements TaskInterface
|
||||
{
|
||||
public function findAll($filters = [], $limit = null, $offset = null)
|
||||
{
|
||||
return Task::when(true, function ($query) use ($filters) {
|
||||
$query->whereNull("parent_id");
|
||||
|
||||
if (isset($filters["search"])) {
|
||||
$search = $filters['search'];
|
||||
$query->whereAny(['title'], 'LIKE', "%$search%");
|
||||
}
|
||||
|
||||
if (isset($filters["status"])) {
|
||||
$query->where("status", $filters["status"]);
|
||||
}
|
||||
|
||||
if (isset($filters["priority"])) {
|
||||
$query->where("priority", $filters["priority"]);
|
||||
}
|
||||
|
||||
if (isset($filters["date"])) {
|
||||
$explodeDate = explode("to", $filters['date']);
|
||||
$query->whereBetween("start_date", [$explodeDate[0], preg_replace('/\s+/', '', $explodeDate[1])]);
|
||||
}
|
||||
|
||||
if (isset($filters["assigned_to"])) {
|
||||
$query->whereJsonContains("assigned_id->ids", (string) $filters['assigned_to']);
|
||||
}
|
||||
|
||||
if (auth()->user()->hasRole('employee')) {
|
||||
$assigned_id = auth()->user()->employee_id;
|
||||
$query->whereJsonContains("assigned_id->ids", (string) $assigned_id);
|
||||
}
|
||||
|
||||
})
|
||||
->with('assignedUser:id,first_name,middle_name,last_name,profile_picture')
|
||||
->latest()
|
||||
->limit($limit)
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getTaskById($TaskId)
|
||||
{
|
||||
return Task::findOrFail($TaskId);
|
||||
}
|
||||
|
||||
public function delete($TaskId)
|
||||
{
|
||||
Task::destroy($TaskId);
|
||||
}
|
||||
|
||||
public function create($TaskDetails)
|
||||
{
|
||||
return Task::create($TaskDetails);
|
||||
}
|
||||
|
||||
public function update($TaskId, array $newDetails)
|
||||
{
|
||||
return Task::whereId($TaskId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck()
|
||||
{
|
||||
return Task::pluck(DB::raw('CONCAT(first_name," ", middle_name , " ",last_name) AS full_name'), 'id');
|
||||
}
|
||||
|
||||
public function getAllTasks($filters = [])
|
||||
{
|
||||
return Task::with('subTask')->when(true, function ($query) use ($filters) {
|
||||
$query->whereNull("parent_id");
|
||||
if (isset($filters["project_id"])) {
|
||||
$query->where("project_id", $filters["project_id"]);
|
||||
}
|
||||
|
||||
if (isset($filters["date"])) {
|
||||
$explodeDate = explode("to", $filters['date']);
|
||||
$query->whereBetween("start_date", [$explodeDate[0], preg_replace('/\s+/', '', $explodeDate[1])]);
|
||||
}
|
||||
|
||||
})
|
||||
// ->latest()
|
||||
->get();
|
||||
}
|
||||
|
||||
public function findAllWithRelations(array $relations = [], $limit = null)
|
||||
{
|
||||
$query = Task::with($relations);
|
||||
if ($limit) {
|
||||
$query->limit($limit);
|
||||
}
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function getTaskCountsByCategory($userId = null)
|
||||
{
|
||||
$query = KanbanColumn::select('category', DB::raw('COUNT(tbl_tasks.id) as task_count'))
|
||||
->leftJoin('tbl_tasks', 'kanban_columns.id', '=', 'tbl_tasks.status');
|
||||
|
||||
// Filter by user ID if provided
|
||||
if ($userId) {
|
||||
$query->whereJsonContains('tbl_tasks.assigned_id->ids', (string) $userId);
|
||||
}
|
||||
|
||||
return $query->groupBy('kanban_columns.category')->get();
|
||||
}
|
||||
|
||||
|
||||
}
|
15
Modules/PMS/app/Repositories/TaskTimeInterface.php
Normal file
15
Modules/PMS/app/Repositories/TaskTimeInterface.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
|
||||
interface TaskTimeInterface
|
||||
{
|
||||
public function findAll($filters = [], $limit = null, $offset = null);
|
||||
public function getTaskTimeById($clientId);
|
||||
public function delete($clientId);
|
||||
public function create($clientDetails);
|
||||
public function update($clientId, array $newDetails);
|
||||
public function pluck();
|
||||
public function getLatestTimeByTaskId($TaskId);
|
||||
|
||||
}
|
65
Modules/PMS/app/Repositories/TaskTimeRepository.php
Normal file
65
Modules/PMS/app/Repositories/TaskTimeRepository.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\PMS\Models\TaskTime;
|
||||
|
||||
class TaskTimeRepository implements TaskTimeInterface
|
||||
{
|
||||
public function findAll($filters = [], $limit = null, $offset = null)
|
||||
{
|
||||
return TaskTime::when(true, function ($query) use ($filters) {
|
||||
$query->whereNull("parent_id");
|
||||
|
||||
if (isset($filters["search"])) {
|
||||
$search = $filters['search'];
|
||||
$query->whereAny(['title'], 'LIKE', "%$search%");
|
||||
}
|
||||
|
||||
if (isset($filters["status"])) {
|
||||
$query->where("status", $filters["status"]);
|
||||
}
|
||||
|
||||
if (isset($filters["date"])) {
|
||||
$explodeDate = explode("to", $filters['date']);
|
||||
$query->whereBetween("start_date", [$explodeDate[0], preg_replace('/\s+/', '', $explodeDate[1])]);
|
||||
}
|
||||
|
||||
})
|
||||
->latest()
|
||||
->limit(5)
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getTaskTimeById($TaskId)
|
||||
{
|
||||
return TaskTime::findOrFail($TaskId);
|
||||
}
|
||||
|
||||
public function delete($TaskId)
|
||||
{
|
||||
TaskTime::destroy($TaskId);
|
||||
}
|
||||
|
||||
public function create($TaskDetails)
|
||||
{
|
||||
return TaskTime::create($TaskDetails);
|
||||
}
|
||||
|
||||
public function update($TaskId, array $newDetails)
|
||||
{
|
||||
return TaskTime::whereId($TaskId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck()
|
||||
{
|
||||
return TaskTime::pluck(DB::raw('CONCAT(first_name," ", middle_name , " ",last_name) AS full_name'), 'id');
|
||||
}
|
||||
|
||||
public function getLatestTimeByTaskId($TaskId)
|
||||
{
|
||||
return TaskTime::where('task_id', $TaskId)->latest()->first();
|
||||
}
|
||||
|
||||
}
|
17
Modules/PMS/app/Repositories/TicketInterface.php
Normal file
17
Modules/PMS/app/Repositories/TicketInterface.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
|
||||
interface TicketInterface
|
||||
{
|
||||
public function findAll();
|
||||
|
||||
public function getTicketById($clientId);
|
||||
|
||||
public function delete($clientId);
|
||||
public function create($clientDetails);
|
||||
public function update($clientId, array $newDetails);
|
||||
public function pluck();
|
||||
public function count();
|
||||
|
||||
}
|
43
Modules/PMS/app/Repositories/TicketRepository.php
Normal file
43
Modules/PMS/app/Repositories/TicketRepository.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\PMS\Models\Ticket;
|
||||
|
||||
class TicketRepository implements TicketInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Ticket::paginate(20);
|
||||
|
||||
}
|
||||
|
||||
public function getTicketById($TicketId)
|
||||
{
|
||||
return Ticket::findOrFail($TicketId);
|
||||
}
|
||||
|
||||
public function delete($TicketId)
|
||||
{
|
||||
Ticket::destroy($TicketId);
|
||||
}
|
||||
|
||||
public function create($TicketDetails)
|
||||
{
|
||||
return Ticket::create($TicketDetails);
|
||||
}
|
||||
|
||||
public function update($TicketId, array $newDetails)
|
||||
{
|
||||
return Ticket::whereId($TicketId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck()
|
||||
{
|
||||
return Ticket::pluck('Ticket_name', 'id');
|
||||
}
|
||||
public function count()
|
||||
{
|
||||
return Ticket::count();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user