Skip to content

Employee leave #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 1, 2017
Merged

Employee leave #14

merged 9 commits into from
Aug 1, 2017

Conversation

vtozija
Copy link
Contributor

@vtozija vtozija commented Jul 14, 2017

  1. Employees asking for leave added in employee panel
  2. Admins apporving employee's leave added in admin panel

*/
public function getDatatable(EmployeeRepository $employeeRepository)
{
$id = $employeeRepository->findBy('email', Auth::user()->email)->first()->id;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get the id the same way as you get the email
Auth::user()->id

public function getDatatable(EmployeeRepository $employeeRepository)
{
$id = $employeeRepository->findBy('email', Auth::user()->email)->first()->id;
return Datatables::of($this->employeeLeaveRepository->findBy('user_id', $id, ['id', 'user_id', 'leave_type_id', 'start_date', 'end_date', 'approved']))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the user column in the table, nor the form for adding new leaves. This is for the logged user only and that info is redundant.

*/
public function store(EmployeeLeaveRequest $request)
{
$employeeLeaveData = $request->all();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's very insecure to get the user id from the input request. Even though I only have the option to choose my user from the dropdown, I could inspect the element and change it's value before submitting the form. If I know the id of some other employee, I could easily request a leave in their name.

$path = $request->attachment->store('uploads/leaves');
$employeeLeaveData['attachment'] = $path;
}
$employeeLeaveData['approved'] = "pending";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using status columns, always use boolean instead of a string. We have only two values available and keeping strings instead wastes unnecessary resources.

* @param \App\Modules\Pim\Repositories\EmployeeRepository $employeeRepository
* @return \Illuminate\Http\Response
*/
public function edit($id, LeaveTypeRepository $leaveTypeRepository, EmployeeRepository $employeeRepository)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to have additional check in case the user opens other person's leave request. The way it is now, if I have the request id I could open the edit page and change the details.

* @param \App\Modules\Leave\Http\Requests\EmployeeLeaveRequest $request
* @return \Illuminate\Http\Response
*/
public function store(EmployeeLeaveRequest $request)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need separate request for this because the user id is picked up from session, not input.

@@ -987,4 +987,34 @@
Breadcrumbs::register('employee.home', function($breadcrumbs)
{
$breadcrumbs->push(trans('app.home'), route('employee.home'));
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breadcrumbs should go to leaves, not back to home page directly.

$breadcrumbs->push($breadcrumb['title'], route('employee.leaves.update', $breadcrumb['id']));
});

Breadcrumbs::register('employee.leaves.destroy', function($breadcrumbs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only add breadcrumbs for existing pages, destroy doesn't need a breadcrumb.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for update.

@trajchevska trajchevska merged commit 3cf2eaf into master Aug 1, 2017
@trajchevska trajchevska deleted the employee_leave branch August 1, 2017 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants