refactor: code style changes

Signed-off-by: miguel456 <me@nogueira.codes>
This commit is contained in:
2023-01-15 00:04:00 +00:00
parent 25155bff2e
commit 3727c84f3e
146 changed files with 1013 additions and 1341 deletions

View File

@@ -5,24 +5,20 @@ namespace App\Http\Controllers;
use App\Absence;
use App\Exceptions\AbsenceNotActionableException;
use App\Http\Requests\StoreAbsenceRequest;
use App\Http\Requests\UpdateAbsenceRequest;
use App\Services\AbsenceService;
use App\User;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
class AbsenceController extends Controller
{
private AbsenceService $absenceService;
public function __construct (AbsenceService $absenceService) {
public function __construct(AbsenceService $absenceService)
{
$this->absenceService = $absenceService;
}
/**
@@ -38,11 +34,11 @@ class AbsenceController extends Controller
->with('absences', Absence::paginate(6));
}
/**
* Display a listing of absences belonging to the current user.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*
* @throws AuthorizationException
*/
public function showUserAbsences()
@@ -54,11 +50,8 @@ class AbsenceController extends Controller
return view('dashboard.absences.own')
->with('absences', $absences);
}
/**
* Show the form for creating a new absence request.
*
@@ -98,7 +91,8 @@ class AbsenceController extends Controller
/**
* Display the specified absence request.
*
* @param \App\Absence $absence
* @param \App\Absence $absence
*
* @throws AuthorizationException
*/
public function show(Absence $absence)
@@ -107,28 +101,26 @@ class AbsenceController extends Controller
return view('dashboard.absences.view')
->with([
'absence' => $absence,
'totalDays' => Carbon::parse($absence->start)->diffInDays($absence->predicted_end)
'absence' => $absence,
'totalDays' => Carbon::parse($absence->start)->diffInDays($absence->predicted_end),
]);
}
/**
* Approve the specified absence.
*
* @param Absence $absence
* @param Absence $absence
* @return RedirectResponse
*
* @throws AuthorizationException
*/
public function approveAbsence(Absence $absence): RedirectResponse
{
$this->authorize('approve', $absence);
try
{
try {
$this->absenceService->approveAbsence($absence);
}
catch (AbsenceNotActionableException $notActionableException)
{
} catch (AbsenceNotActionableException $notActionableException) {
return redirect()
->back()
->with('error', $notActionableException->getMessage());
@@ -139,23 +131,21 @@ class AbsenceController extends Controller
->with('success', __('Absence request successfully approved. It will automatically transition to "Ended" on its predicted end date.'));
}
/**
* Decline the specified absence.
*
* @param Absence $absence
* @param Absence $absence
* @return RedirectResponse
*
* @throws AuthorizationException
*/
public function declineAbsence(Absence $absence): RedirectResponse
{
$this->authorize('decline', $absence);
try
{
try {
$this->absenceService->declineAbsence($absence);
} catch (AbsenceNotActionableException $notActionableException)
{
} catch (AbsenceNotActionableException $notActionableException) {
return redirect()
->back()
->with('error', $notActionableException->getMessage());
@@ -166,24 +156,21 @@ class AbsenceController extends Controller
->with('success', __('Absence request successfully declined.'));
}
/**
* Cancel the specified absence.
*
* @param Absence $absence
* @param Absence $absence
* @return \Illuminate\Http\RedirectResponse
*
* @throws AuthorizationException
*/
public function cancelAbsence(Absence $absence): \Illuminate\Http\RedirectResponse
public function cancelAbsence(Absence $absence): RedirectResponse
{
$this->authorize('cancel', $absence);
try
{
try {
$this->absenceService->cancelAbsence($absence);
}
catch (AbsenceNotActionableException $notActionableException)
{
} catch (AbsenceNotActionableException $notActionableException) {
return redirect()
->back()
->with('error', $notActionableException->getMessage());