Add application list for users

This commit is contained in:
Miguel Nogueira 2020-05-11 16:44:47 +01:00
parent f46a941b61
commit 7635f8e2f4
6 changed files with 80 additions and 44 deletions

View File

@ -13,4 +13,9 @@ class Application extends Model
'applicantStatus'
];
public function user()
{
return $this->belongsTo('App\User', 'applicantUserID', 'id');
}
}

View File

@ -13,20 +13,13 @@ use Illuminate\Support\Facades\Validator;
class ApplicationController extends Controller
{
public function showPendingUserApps()
public function showUserApps()
{
return view('dashboard.user.applications');
return view('dashboard.user.applications')
->with('applications', Auth::user()->applications);
}
public function showDeniedUserApps()
{
return view('dashboard.user.deniedapplications');
}
public function showApprovedApps()
{
return view('dashboard.user.approvedapplications');
}
public function showAllPendingApps()
{

View File

@ -36,4 +36,9 @@ class User extends Authenticatable
protected $casts = [
'email_verified_at' => 'datetime',
];
public function applications()
{
return $this->hasMany('App\Application', 'applicantUserID', 'id');
}
}

View File

@ -214,19 +214,9 @@ return [
'icon' => 'fas fa-fw fa-list-ul',
'submenu' => [
[
'text' => 'Under Review',
'text' => 'Current Applications',
'icon' => 'fas fa-fw fa-check-double',
'url' => '/applications/pending'
],
[
'text' => 'Denied',
'icon' => 'fas fa-fw fa-times',
'url' => '/applications/denied'
],
[
'text' => 'Approved',
'icon' => 'fas fa-fw fa-user-check',
'url' => '/applications/approved'
'url' => '/applications/current'
]
]

View File

@ -39,6 +39,18 @@
<p>If an interview is scheduled, you'll need to open your application here and confirm the time, date, and location assigned for you.</p>
</div>
<div class="alert alert-info">
<b><i class="fa fa-info-circle"></i> Account Standing</b>
<p>Your account is currently <b>{{($isEligibleForApplication) ? 'eligible' : 'not eligible'}}</b> for application.</p>
@if (!$isEligibleForApplication)
<p>As of today, there are <b>{{$eligibilityDaysRemaining}} days</b> remaining until you're permitted to submit another application.</p>
@endif
<i class="text-sm">Powered by Carbon</i>
</div>
</div>
</div>
@ -60,25 +72,59 @@
<th style="width: 10px">#</th>
<th>Applicant</th>
<th>Application Date</th>
<th>Updated On</th>
<th>Last Acted On</th>
<th style="width: 40px">Status</th>
<th style="width: 40px">Actions</th>
</tr>
</thead>
<tbody>
@foreach ($applications as $application)
<tr>
<td>1.</td>
<td>Jonathan Smith</td>
<td>2020-04-28</td>
<td>2020-04-29</td>
<td><span class="badge bg-success">Approved</span></td>
<td>{{$application->id}}</td>
<td>{{Auth::user()->name}}</td>
<td>{{$application->created_at}}</td>
<td>{{$application->updated_at}}</td>
<td>
@switch($application->applicationStatus)
<button type="button" class="btn btn-success btn-sm">View</button>
<button type="button" class="btn btn-danger btn-sm">Withdraw</button>
@case('STAGE_SUBMITTED')
<span class="badge badge-success"><i class="fas fa-paper-plane"></i> Submitted</span>
@break
@case('STAGE_PEERAPPROVAL')
<span class="badge badge-warning"><i class="fas fa-users"></i> Peer Approval</span>
@break
@case('STAGE_INTERVIEW')
<span class="badge badge-info"><i class="fa fa-microphone-alt"></i> Interview</span>
@break
@case('STAGE_INTERVIEW_SCHEDULED')
<span class="badge badge-warning"><i class="fa fa-clock"></i> Interview Scheduled</span>
@break
@case('APPROVED')
<span class="badge badge-success"><i class="fa fa-check-double"></i> Approved</span>
@break
@case('DENIED')
<span class="badge badge-danger"><i class="fa fa-ban"></i> <b>Denied</b></span>
@break
@default
<span class="badge badge-danger"><i class="fa fa-question"></i> Unknown</span>
@endswitch
</td>
<td>
<button type="button" class="btn btn-success"><i class="fa fa-eye"></i> View</button>
</td>
</tr>
@endforeach
</tbody>
</table>
@ -88,8 +134,6 @@
<div class="card-footer">
<button type="button" class="btn btn-default mr-2">Back</button>
<button type="button" class="btn btn-info mr-2">Approved Applications</button>
<button type="button" class="btn btn-info mr-2">Denied Applications</button>
</div>
</div>

View File

@ -21,16 +21,15 @@ Route::post('/form/contact', 'ContactController@create')
Route::group(['middleware' => 'auth'], function(){
Route::get('/dashboard', 'DashboardController@index')->middleware('eligibility');
Route::get('/dashboard', 'DashboardController@index')
->name('dashboard')
->middleware('eligibility');
Route::group(['prefix' => '/applications'], function (){
Route::get('/pending', 'ApplicationController@showPendingUserApps')
->name('userPendingApps');
Route::get('/denied', 'ApplicationController@showDeniedUserApps')
->name('userDeniedApps');
Route::get('/approved', 'ApplicationController@showApprovedApps')
->name('userApprovedApps');
Route::get('/current', 'ApplicationController@showUserApps')
->name('showUserApps')
->middleware('eligibility');
Route::get('/staff/outstanding', 'ApplicationController@showAllPendingApps')