first commit
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/ClientInterface.php
Normal file
14
Modules/PMS/app/Repositories/ClientInterface.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
|
||||
interface ClientInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getClientById($clientId);
|
||||
public function delete($clientId);
|
||||
public function create($clientDetails);
|
||||
public function update($clientId, array $newDetails);
|
||||
public function pluck();
|
||||
|
||||
}
|
39
Modules/PMS/app/Repositories/ClientRepository.php
Normal file
39
Modules/PMS/app/Repositories/ClientRepository.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
|
||||
use Modules\PMS\Models\Client;
|
||||
|
||||
class ClientRepository implements ClientInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Client::paginate(20);
|
||||
}
|
||||
|
||||
public function getClientById($ClientId)
|
||||
{
|
||||
return Client::findOrFail($ClientId);
|
||||
}
|
||||
|
||||
public function delete($ClientId)
|
||||
{
|
||||
Client::destroy($ClientId);
|
||||
}
|
||||
|
||||
public function create($ClientDetails)
|
||||
{
|
||||
return Client::create($ClientDetails);
|
||||
}
|
||||
|
||||
public function update($ClientId, array $newDetails)
|
||||
{
|
||||
return Client::whereId($ClientId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck()
|
||||
{
|
||||
return Client::pluck('client_name', 'id');
|
||||
}
|
||||
|
||||
}
|
14
Modules/PMS/app/Repositories/ProjectInterface.php
Normal file
14
Modules/PMS/app/Repositories/ProjectInterface.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
|
||||
interface ProjectInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getProjectById($clientId);
|
||||
public function delete($clientId);
|
||||
public function create($clientDetails);
|
||||
public function update($clientId, array $newDetails);
|
||||
public function pluck();
|
||||
|
||||
}
|
39
Modules/PMS/app/Repositories/ProjectRepository.php
Normal file
39
Modules/PMS/app/Repositories/ProjectRepository.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
|
||||
use Modules\PMS\Models\Project;
|
||||
|
||||
class ProjectRepository implements ProjectInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Project::paginate(20);
|
||||
}
|
||||
|
||||
public function getProjectById($ProjectId)
|
||||
{
|
||||
return Project::findOrFail($ProjectId);
|
||||
}
|
||||
|
||||
public function delete($ProjectId)
|
||||
{
|
||||
Project::destroy($ProjectId);
|
||||
}
|
||||
|
||||
public function create($ProjectDetails)
|
||||
{
|
||||
return Project::create($ProjectDetails);
|
||||
}
|
||||
|
||||
public function update($ProjectId, array $newDetails)
|
||||
{
|
||||
return Project::whereId($ProjectId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function pluck()
|
||||
{
|
||||
return Project::pluck('project_name', 'id');
|
||||
}
|
||||
|
||||
}
|
14
Modules/PMS/app/Repositories/TaskInterface.php
Normal file
14
Modules/PMS/app/Repositories/TaskInterface.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?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();
|
||||
|
||||
}
|
56
Modules/PMS/app/Repositories/TaskRepository.php
Normal file
56
Modules/PMS/app/Repositories/TaskRepository.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\PMS\Models\Task;
|
||||
|
||||
class TaskRepository implements TaskInterface
|
||||
{
|
||||
public function findAll($filters = [], $limit = null, $offset = null)
|
||||
{
|
||||
return Task::when($filters, function ($query) use ($filters) {
|
||||
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']);
|
||||
// dd($filters['date'], preg_replace('/\s+/', '', $explodeDate[1]));
|
||||
$query->whereBetween("start_date", [$explodeDate[0], preg_replace('/\s+/', '', $explodeDate[1])]);
|
||||
}
|
||||
|
||||
})->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');
|
||||
}
|
||||
|
||||
}
|
16
Modules/PMS/app/Repositories/TicketInterface.php
Normal file
16
Modules/PMS/app/Repositories/TicketInterface.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?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();
|
||||
|
||||
}
|
40
Modules/PMS/app/Repositories/TicketRepository.php
Normal file
40
Modules/PMS/app/Repositories/TicketRepository.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?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');
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user