Skip to content

Commit

Permalink
(Fix) Applications Signups Validation 🐛
Browse files Browse the repository at this point in the history
- closes #561
  • Loading branch information
HDVinnie committed Feb 5, 2019
1 parent 12e6def commit 2a8896f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 20 deletions.
21 changes: 12 additions & 9 deletions app/Http/Controllers/Staff/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,22 @@ public function approve(Request $request, $id)
$invite->email = $application->email;
$invite->code = $code;
$invite->expires_on = $current->copy()->addDays(config('other.invite_expire'));
$invite->custom = $request->input('approve_message');
$invite->custom = $request->input('approve');

if (config('email-white-blacklist.enabled') === 'allow') {
$v = validator($invite->toArray(), [
$v = validator($request->all(), [
'email' => 'required|email|unique:invites|unique:users|email_list:allow', // Whitelist
'custom' => 'required',
'approve' => 'required',
]);
} elseif (config('email-white-blacklist.enabled') === 'block') {
$v = validator($invite->toArray(), [
$v = validator($request->all(), [
'email' => 'required|email|unique:invites|unique:users|email_list:block', // Blacklist
'custom' => 'required',
'approve' => 'required',
]);
} else {
$v = validator($invite->toArray(), [
$v = validator($request->all(), [
'email' => 'required|email|unique:invites|unique:users', // Default
'custom' => 'required',
'approve' => 'required',
]);
}

Expand Down Expand Up @@ -140,9 +140,12 @@ public function reject(Request $request, $id)
$application = Application::withAnyStatus()->findOrFail($id);

if ($application->status !== 2) {
$application->markRejected();
$denied_message = $request->input('denied_message');
$denied_message = $request->input('deny');
$v = validator($request->all(), [
'deny' => 'required',
]);

$application->markRejected();
Mail::to($application->email)->send(new DenyApplication($denied_message));

return redirect()->route('staff.applications.index')
Expand Down
39 changes: 30 additions & 9 deletions resources/views/Staff/application/show.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
@extends('layout.default')

@section('title')
<title>Application - {{ config('other.title') }}</title>
<title>Application - Staff Dashboard - {{ config('other.title') }}</title>
@endsection

@section('meta')
<meta name="description" content="Application - Staff Dashboard">
@endsection

@section('breadcrumb')
Expand Down Expand Up @@ -123,46 +127,63 @@
<button type="button" class="btn btn-sm btn-success" data-toggle="modal" data-target="#approve-application"><i class="{{ config('other.font-awesome') }} fa-check"></i> Approve</button>

<div id="approve-application" class="modal fade" role="dialog">
<form method="post" action="{{ route('staff.applications.approve', ['id' => $application->id]) }}">
@csrf
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Approve This Application</h4>
</div>
<div class="modal-body">
<textarea title="Approval Message To Applicant" class="form-control" rows="5" cols="50" name="approve_message"></textarea>
<input id="email" name="email" type="hidden" value="{{ $application->email }}">
<div class="form-group">
<label for="message">@lang('common.message')</label>
</div>
<div class="form-group">
<textarea class="form-control" rows="5" cols="50" name="approve" id="approve"></textarea>
</div>
</div>
<div class="modal-footer">
<a href="{{ route('staff.applications.approve', ['id' => $application->id]) }}"
class="btn btn-success">
<button class="btn btn-success" type="submit">
<i class="{{ config('other.font-awesome') }} fa-check"></i> Approve
</a>
</button>
</div>
</div>
</div>
</form>
</div>

<button type="button" class="btn btn-sm btn-danger" data-toggle="modal" data-target="#deny-application"><i class="{{ config('other.font-awesome') }} fa-times"></i> Reject</button>

<div id="deny-application" class="modal fade" role="dialog">
<form method="post" action="{{ route('staff.applications.reject', ['id' => $application->id]) }}">
@csrf
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Deny This Application</h4>
</div>
<div class="modal-body">
<textarea title="Denied Message To Applicant" class="form-control" rows="5" cols="50" name="denied_message"></textarea>
<input id="email" name="email" type="hidden" value="{{ $application->email }}">
<div class="form-group">
<label for="message">@lang('common.message')</label>
</div>
<div class="form-group">
<textarea class="form-control" rows="5" cols="50" name="deny" id="deny"></textarea>
</div>
</div>
<div class="modal-footer">
<a href="{{ route('staff.applications.reject', ['id' => $application->id]) }}"
class="btn btn-danger">
<button class="btn btn-danger" type="submit">
<i class="{{ config('other.font-awesome') }} fa-times"></i> Reject
</a>
</button>
</div>
</div>
</div>
</form>
</div>

</td>
</tr>
@endif
Expand Down
4 changes: 2 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@
// Applications System
Route::get('/applications', 'ApplicationController@index')->name('staff.applications.index');
Route::get('/applications/{id}', 'ApplicationController@show')->name('staff.applications.show');
Route::get('/applications/{id}/approve', 'ApplicationController@approve')->name('staff.applications.approve');
Route::get('/applications/{id}/reject', 'ApplicationController@reject')->name('staff.applications.reject');
Route::post('/applications/{id}/approve', 'ApplicationController@approve')->name('staff.applications.approve');
Route::post('/applications/{id}/reject', 'ApplicationController@reject')->name('staff.applications.reject');
});
});

0 comments on commit 2a8896f

Please sign in to comment.