first commit

This commit is contained in:
Sampanna Rimal
2024-08-27 17:48:06 +05:45
commit 53c0140f58
10839 changed files with 1125847 additions and 0 deletions

View File

@@ -0,0 +1,121 @@
<?php
namespace Modules\PMS\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Admin\Repositories\CountryRepository;
use Modules\Admin\Repositories\FieldRepository;
use Modules\PMS\Models\Client;
use Modules\PMS\Repositories\ClientInterface;
class ClientController extends Controller
{
private $clientRepository;
private $fieldRepository;
private $countryRepository;
public function __construct(ClientInterface $clientRepository, FieldRepository $fieldRepository, CountryRepository $countryRepository)
{
$this->clientRepository = $clientRepository;
$this->fieldRepository = $fieldRepository;
$this->countryRepository = $countryRepository;
}
/**
* Display a listing of the resource.
*/
public function index()
{
$data['title'] = 'Client List';
$data['clients'] = $this->clientRepository->findAll();
return view('pms::client.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Client';
$data['status'] = Client::STATUS;
$data['editable'] = false;
$data['genderList'] = $this->fieldRepository->getDropdownByAlias('gender');
$data['salutationList'] = $this->fieldRepository->getDropdownByAlias('salutation');
$data['countryList'] = $this->countryRepository->pluck();
return view('pms::client.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$inputData = $request->all();
try {
$this->clientRepository->create($inputData);
toastr()->success('Client Created Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return redirect()->route('client.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
$data['title'] = 'View Client';
$data['status'] = Client::STATUS;
$data['client'] = $this->clientRepository->getClientById($id);
return view('pms::client.show', $data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit Client';
$data['status'] = Client::STATUS;
$data['editable'] = true;
$data['client'] = $this->clientRepository->getClientById($id);
$data['genderList'] = $this->fieldRepository->getDropdownByAlias('gender');
$data['salutationList'] = $this->fieldRepository->getDropdownByAlias('salutation');
$data['countryList'] = $this->countryRepository->pluck();
return view('pms::client.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$inputData = $request->except(['_method', '_token']);
try {
$this->clientRepository->update($id, $inputData);
toastr()->success('Client Update Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return redirect()->route('client.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
try {
$this->clientRepository->delete($id);
toastr()->success('Client Deleted Succesfully');
} catch (\Throwable $th) {
//throw $th;
toastr()->error($th->getMessage());
}
}
}

View File

@@ -0,0 +1,67 @@
<?php
namespace Modules\PMS\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class PMSController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
return view('pms::index');
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('pms::create');
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
//
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('pms::show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
return view('pms::edit');
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
//
}
}

View File

@@ -0,0 +1,136 @@
<?php
namespace Modules\PMS\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Employee\Repositories\EmployeeInterface;
use Modules\PMS\Models\Project;
use Modules\PMS\Repositories\ClientInterface;
use Modules\PMS\Repositories\ProjectInterface;
class ProjectController extends Controller
{
private $projectRepository;
private $clientRepository;
private $employeeRepository;
public function __construct(
ProjectInterface $projectRepository,
ClientInterface $clientRepository,
EmployeeInterface $employeeRepository) {
$this->projectRepository = $projectRepository;
$this->clientRepository = $clientRepository;
$this->employeeRepository = $employeeRepository;
}
/**
* Display a listing of the resource.
*/
public function index()
{
$data['title'] = 'Project List';
$data['projects'] = $this->projectRepository->findAll();
// ->map(function ($project) {
// return $project;
// });
// dd($data['projects']->toArray());
return view('pms::project.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Project';
$data['status'] = Project::STATUS;
$data['categoryList'] = Project::CATEGORY;
$data['clientList'] = $this->clientRepository->pluck();
$data['memberList'] = $this->employeeRepository->pluck();
$data['departmentList'] = [];
return view('pms::project.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$inputData = $request->all();
// dd($inputData);
// try {
$this->projectRepository->create($inputData);
foreach($request->members_id as $memberId) {
$employeemodel=$this->employeeRepository->getEmployeeById($memberId);
// dd($employeemodel->user);
sendNotification($employeemodel->user, [
'msg' => 'You have been assigned to a Project', ]);
}
toastr()->success('Project Created Succesfully');
// } catch (\Throwable $th) {
// toastr()->error($th->getMessage());
// }
return redirect()->route('project.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
$data['title'] = 'View Project';
$data['project'] = $this->projectRepository->getProjectById($id);
$data['status'] = Project::STATUS;
$data['countryList'] = [1 => 'Nepal'];
return view('pms::project.show', $data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit Project';
$data['project'] = $this->projectRepository->getProjectById($id);
$data['status'] = Project::STATUS;
$data['categoryList'] = Project::CATEGORY;
$data['clientList'] = $this->clientRepository->pluck();
$data['memberList'] = $this->employeeRepository->pluck();
$data['departmentList'] = [];
return view('pms::project.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$inputData = $request->except(['_method', '_token']);
try {
$this->projectRepository->update($id, $inputData);
toastr()->success('Project Update Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return redirect()->route('project.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
try {
$this->projectRepository->delete($id);
toastr()->success('Project Deleted Succesfully');
} catch (\Throwable $th) {
//throw $th;
toastr()->error($th->getMessage());
}
}
}

View File

@@ -0,0 +1,162 @@
<?php
namespace Modules\PMS\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Employee\Repositories\EmployeeInterface;
use Modules\PMS\Models\Task;
use Modules\PMS\Repositories\ProjectInterface;
use Modules\PMS\Repositories\TaskInterface;
class TaskController extends Controller
{
private $taskRepository;
private $projectRepository;
private $employeeRepository;
public function __construct(
TaskInterface $taskRepository,
ProjectInterface $projectRepository,
EmployeeInterface $employeeRepository) {
$this->taskRepository = $taskRepository;
$this->projectRepository = $projectRepository;
$this->employeeRepository = $employeeRepository;
}
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
$filters = $request->all();
$data['title'] = 'Task List';
$data['tasks'] = $this->taskRepository->findAll($filters);
$data['statusList'] = Task::STATUS;
// dd($data['tasks']->toArray());
return view('pms::task.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Task';
$data['status'] = Task::STATUS;
$data['priority'] = Task::PRIORITY;
$data['categoryList'] = Task::CATEGORY;
$data['projectList'] = $this->projectRepository->pluck();
$data['memberList'] = $this->employeeRepository->pluck();
return view('pms::task.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$inputData = $request->all();
try {
$this->taskRepository->create($inputData);
foreach($request->assigned_id as $memberId) {
$employeemodel=$this->employeeRepository->getEmployeeById($memberId);
// dd($employeemodel->user);
sendNotification($employeemodel->user, [
'msg' => 'A Task has been assigned to you', ]);
}
toastr()->success('Task Created Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return redirect()->route('task.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
$data['title'] = 'View Task';
$data['task'] = $this->taskRepository->getTaskById($id);
$data['status'] = Task::STATUS;
return view('pms::task.show', $data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit Task';
$data['task'] = $this->taskRepository->getTaskById($id);
$data['status'] = Task::STATUS;
$data['priority'] = Task::PRIORITY;
$data['categoryList'] = Task::CATEGORY;
$data['projectList'] = $this->projectRepository->pluck();
$data['memberList'] = $this->employeeRepository->pluck();
return view('pms::task.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$inputData = $request->except(['_method', '_token']);
try {
$this->taskRepository->update($id, $inputData);
toastr()->success('Task Update Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return redirect()->route('task.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
try {
$this->taskRepository->delete($id);
toastr()->success('Task Deleted Succesfully');
} catch (\Throwable $th) {
//throw $th;
toastr()->error($th->getMessage());
}
}
public function kanban()
{
$data['title'] = 'Kanban Board';
$data['tasks'] = Task::select('*')->get()->groupBy('status');
$data['statusList'] = Task::STATUS;
return view('pms::task.kanban', $data);
}
public function changeStatus(Request $request)
{
try {
$taskModel = $this->taskRepository->getTaskById($request->id);
$taskModel->status = $request->changeStatus;
$taskModel->save();
return response()->json([
'status' => true,
'msg' => 'Status Changed',
], 200);
} catch (\Throwable $th) {
return response()->json([
'status' => false,
'msg' => $th->getMessage(),
], 400);
}
}
}

View File

@@ -0,0 +1,101 @@
<?php
namespace Modules\PMS\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\PMS\Models\Ticket;
use Modules\PMS\Repositories\TicketInterface;
class TicketController extends Controller
{
private $ticketRepository;
public function __construct(TicketInterface $ticketRepository)
{
$this->ticketRepository = $ticketRepository;
}
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
$data['title'] = 'Ticket List';
$data['tickets'] = $this->ticketRepository->findAll();
$data['statusList'] = Ticket::STATUS;
return view('pms::ticket.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Ticket';
$data['statusList'] = Ticket::STATUS;
return view('pms::ticket.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$inputData = $request->all();
$this->ticketRepository->create($inputData);
toastr()->success('Ticket Created Succesfully');
return redirect()->route('ticket.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
$data['title'] = 'View Ticket';
$data['tickets'] = $this->ticketRepository->getTicketById($id);
return view('pms::ticket.show', $data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit Ticket';
$data['ticket'] = $this->ticketRepository->getTicketById($id);
return view('pms::ticket.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$inputData = $request->except(['_method', '_token']);
try {
$this->ticketRepository->update($id, $inputData);
toastr()->success('Ticket Update Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return redirect()->route('ticket.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
try {
$this->ticketRepository->delete($id);
toastr()->success('Ticket Deleted Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
}
}

View File

View File

@@ -0,0 +1,26 @@
<?php
namespace Modules\PMS\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class ClientRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
//
];
}
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
}

View File

View 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'];
}

View 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();
}
}

View 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];
}
}

View 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');
}
}

View File

View File

View File

@@ -0,0 +1,126 @@
<?php
namespace Modules\PMS\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Modules\PMS\Repositories\ClientInterface;
use Modules\PMS\Repositories\ClientRepository;
use Modules\PMS\Repositories\ProjectInterface;
use Modules\PMS\Repositories\ProjectRepository;
use Modules\PMS\Repositories\TaskInterface;
use Modules\PMS\Repositories\TaskRepository;
use Modules\PMS\Repositories\TicketInterface;
use Modules\PMS\Repositories\TicketRepository;
class PMSServiceProvider extends ServiceProvider
{
protected string $moduleName = 'PMS';
protected string $moduleNameLower = 'pms';
/**
* Boot the application events.
*/
public function boot(): void
{
$this->registerCommands();
$this->registerCommandSchedules();
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations'));
}
/**
* Register the service provider.
*/
public function register(): void
{
$this->app->bind(TicketInterface::class, TicketRepository::class);
$this->app->bind(ClientInterface::class, ClientRepository::class);
$this->app->bind(ProjectInterface::class, ProjectRepository::class);
$this->app->bind(TaskInterface::class, TaskRepository::class);
$this->app->register(RouteServiceProvider::class);
}
/**
* Register commands in the format of Command::class
*/
protected function registerCommands(): void
{
// $this->commands([]);
}
/**
* Register command Schedules.
*/
protected function registerCommandSchedules(): void
{
// $this->app->booted(function () {
// $schedule = $this->app->make(Schedule::class);
// $schedule->command('inspire')->hourly();
// });
}
/**
* Register translations.
*/
public function registerTranslations(): void
{
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
$this->loadJsonTranslationsFrom($langPath);
} else {
$this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower);
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang'));
}
}
/**
* Register config.
*/
protected function registerConfig(): void
{
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower . '.php')], 'config');
$this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
}
/**
* Register views.
*/
public function registerViews(): void
{
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
$sourcePath = module_path($this->moduleName, 'resources/views');
$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower . '-module-views']);
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
$componentNamespace = str_replace('/', '\\', config('modules.namespace') . '\\' . $this->moduleName . '\\' . ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', '')));
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
}
/**
* Get the services provided by the provider.
*/
public function provides(): array
{
return [];
}
private function getPublishableViewPaths(): array
{
$paths = [];
foreach (config('view.paths') as $path) {
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
$paths[] = $path . '/modules/' . $this->moduleNameLower;
}
}
return $paths;
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace Modules\PMS\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*/
public function boot(): void
{
parent::boot();
}
/**
* Define the routes for the application.
*/
public function map(): void
{
$this->mapApiRoutes();
$this->mapWebRoutes();
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*/
protected function mapWebRoutes(): void
{
Route::middleware('web')->group(module_path('PMS', '/routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*/
protected function mapApiRoutes(): void
{
Route::middleware('api')->prefix('api')->name('api.')->group(module_path('PMS', '/routes/api.php'));
}
}

View File

View 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();
}

View 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');
}
}

View 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();
}

View 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');
}
}

View 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();
}

View 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');
}
}

View 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();
}

View 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');
}
}