Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #446 from InfyOmLabs/develop
Browse files Browse the repository at this point in the history
v0.1.5-beta Release
  • Loading branch information
mitulgolakiya authored Apr 13, 2020
2 parents 19bef40 + e929554 commit c91387a
Show file tree
Hide file tree
Showing 42 changed files with 3,175 additions and 1,763 deletions.
4 changes: 3 additions & 1 deletion app/Http/Controllers/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Http\Requests\CreateClientRequest;
use App\Http\Requests\UpdateClientRequest;
use App\Models\Client;
use App\Models\Department;
use App\Queries\ClientDataTable;
use App\Repositories\ClientRepository;
use App\Repositories\ProjectRepository;
Expand Down Expand Up @@ -47,8 +48,9 @@ public function index(Request $request)
if ($request->ajax()) {
return Datatables::of((new ClientDataTable())->get())->make(true);
}
$departments = Department::all()->pluck('name', 'id')->toArray();

return view('clients.index');
return view('clients.index', ['departments' => $departments]);
}

/**
Expand Down
117 changes: 117 additions & 0 deletions app/Http/Controllers/DepartmentController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?php

namespace App\Http\Controllers;

use App\Http\Requests\CreateDepartmentRequest;
use App\Http\Requests\UpdateDepartmentRequest;
use App\Models\Department;
use App\Queries\DepartmentDataTable;
use App\Repositories\ClientRepository;
use App\Repositories\DepartmentRepository;
use DataTables;
use Exception;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;

class DepartmentController extends AppBaseController
{
/** @var DepartmentRepository */
private $departmentRepository;

public function __construct(DepartmentRepository $departmentRepo)
{
$this->departmentRepository = $departmentRepo;
}

/**
* Display a listing of the Department.
*
* @param Request $request
*
* @throws Exception
*
* @return Factory|View
*/
public function index(Request $request)
{
if ($request->ajax()) {
return DataTables::of((new DepartmentDataTable())->get())->make(true);
}

return view('departments.index');
}

/**
* Store a newly created Department in storage.
*
* @param CreateDepartmentRequest $request
*
* @return JsonResponse
*/
public function store(CreateDepartmentRequest $request)
{
$input = $request->all();

$this->departmentRepository->create($input);

return $this->sendSuccess('Department created successfully.');
}

/**
* Show the form for editing the specified Department.
*
* @param Department $department
*
* @return JsonResponse
*/
public function edit(Department $department)
{
return $this->sendResponse($department, 'Department retrieved successfully.');
}

/**
* Update the specified Department in storage.
*
* @param Department $department
* @param UpdateDepartmentRequest $request
*
* @return JsonResponse
*/
public function update(Department $department, UpdateDepartmentRequest $request)
{
$this->departmentRepository->update($request->all(), $department->id);

return $this->sendSuccess('Department updated successfully.');
}

/**
* Remove the specified Department from storage.
*
* @param Department $department
*
* @throws Exception
*
* @return JsonResponse
*/
public function destroy(Department $department)
{
$this->departmentRepository->delete($department->id);

return $this->sendSuccess('Department deleted successfully.');
}

/**
* @param Request $request
* @param ClientRepository $clientRepository
*
* @return JsonResponse
*/
public function clients(Request $request, ClientRepository $clientRepository)
{
$projects = $clientRepository->getClientList($request->get('department_id', null));

return $this->sendResponse($projects, 'Clients retrieved successfully.');
}
}
26 changes: 18 additions & 8 deletions app/Http/Controllers/ReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Models\User;
use App\Queries\ReportDataTable;
use App\Repositories\ClientRepository;
use App\Repositories\DepartmentRepository;
use App\Repositories\ProjectRepository;
use App\Repositories\ReportRepository;
use App\Repositories\TagRepository;
Expand All @@ -17,11 +18,12 @@
use DataTables;
use Exception;
use Flash;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Response;
use Illuminate\View\View;

/**
* Class ReportController.
Expand All @@ -43,18 +45,23 @@ class ReportController extends AppBaseController
/** @var ProjectRepository */
private $projectRepo;

/** @var DepartmentRepository */
private $departmentRepo;

public function __construct(
ReportRepository $reportRepo,
UserRepository $userRepository,
ProjectRepository $projectRepository,
ClientRepository $clientRepository,
TagRepository $tagRepository
TagRepository $tagRepository,
DepartmentRepository $departmentRepository
) {
$this->reportRepository = $reportRepo;
$this->userRepo = $userRepository;
$this->clientRepo = $clientRepository;
$this->tagRepo = $tagRepository;
$this->projectRepo = $projectRepository;
$this->departmentRepo = $departmentRepository;
}

/**
Expand All @@ -64,7 +71,7 @@ public function __construct(
*
* @throws Exception
*
* @return Response
* @return Factory|View
*/
public function index(Request $request)
{
Expand All @@ -79,14 +86,15 @@ public function index(Request $request)
/**
* Show the form for creating a new Report.
*
* @return Response
* @return Factory|View
*/
public function create()
{
$data['tags'] = $this->tagRepo->getTagList();
$data['users'] = $this->userRepo->getUserList();
$data['clients'] = $this->clientRepo->getClientList();
$data['projects'] = $this->projectRepo->getProjectsList();
$data['departments'] = $this->departmentRepo->getDepartmentList();

return view('reports.create', $data);
}
Expand All @@ -96,7 +104,7 @@ public function create()
*
* @param CreateReportRequest $request
*
* @return Response
* @return RedirectResponse|Redirector
*/
public function store(CreateReportRequest $request)
{
Expand All @@ -114,7 +122,7 @@ public function store(CreateReportRequest $request)
*
* @param Report $report
*
* @return Response
* @return Factory|View
*/
public function show(Report $report)
{
Expand All @@ -136,7 +144,7 @@ public function show(Report $report)
*
* @param Report $report
*
* @return Response
* @return Factory|View
*/
public function edit(Report $report)
{
Expand All @@ -146,10 +154,12 @@ public function edit(Report $report)
$data['tagIds'] = $this->reportRepository->getTagIds($id);
$data['userIds'] = $this->reportRepository->getUserIds($id);
$data['clientId'] = $this->reportRepository->getClientId($id);
$data['departmentId'] = $this->reportRepository->getDepartmentId($id);
$data['projects'] = $this->projectRepo->getProjectsList($data['clientId']);
$data['users'] = $this->userRepo->getUserList($data['projectIds']);
$data['clients'] = $this->clientRepo->getClientList();
$data['tags'] = $this->tagRepo->getTagList();
$data['departments'] = $this->departmentRepo->getDepartmentList();

return view('reports.edit')->with($data);
}
Expand All @@ -162,7 +172,7 @@ public function edit(Report $report)
*
* @throws Exception
*
* @return Response
* @return RedirectResponse|Redirector
*/
public function update(Report $report, UpdateReportRequest $request)
{
Expand Down
29 changes: 29 additions & 0 deletions app/Http/Requests/CreateDepartmentRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Http\Requests;

use App\Models\Department;
use Illuminate\Foundation\Http\FormRequest;

class CreateDepartmentRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return Department::$rules;
}
}
33 changes: 33 additions & 0 deletions app/Http/Requests/UpdateDepartmentRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\Http\Requests;

use App\Models\Department;
use Illuminate\Foundation\Http\FormRequest;

class UpdateDepartmentRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$id = $this->route('department')->id;
$rules = Department::$rules;
$rules['name'] = 'required|unique:departments,name,'.$id;

return $rules;
}
}
Loading

0 comments on commit c91387a

Please sign in to comment.