This repository has been archived by the owner on Jun 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #446 from InfyOmLabs/develop
v0.1.5-beta Release
- Loading branch information
Showing
42 changed files
with
3,175 additions
and
1,763 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.