Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Commit

Permalink
Added a page to see the perms you took
Browse files Browse the repository at this point in the history
  • Loading branch information
Teddy Roncin committed Aug 28, 2023
1 parent 9b8d3bd commit 6fe5740
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 4 deletions.
12 changes: 10 additions & 2 deletions app/Http/Controllers/Admin/PermController.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function shotgun() {
}

public function doShotgun($id) {
$redirection = redirect(route('perm.shotgun'));
$redirection = redirect(route('dashboard.perm.shotgun'));
$user = Auth::user();
$perm = Perm::find($id);
if ($user->is_newcomer) {
Expand Down Expand Up @@ -385,7 +385,7 @@ public function doShotgun($id) {
}

public function doUnshotgun($id) {
$redirection = redirect(route('perm.shotgun'));
$redirection = redirect(route('dashboard.perm.shotgun'));
$user = Auth::user();
$perm = Perm::find($id);
$found = false;
Expand All @@ -411,4 +411,12 @@ public function doUnshotgun($id) {
$perm->permanenciers()->detach($user->id);
return $redirection->withSuccess('Tu as bien quitté la perm.');
}

public function shotgunedList() {
$user = Auth::user();
$perms = Perm::join('perm_users', 'perm_users.perm_id', '=', 'perms.id')
->where('user_id', '=', $user->id)
->where('respo', '=', 0)->get();
return view('dashboard.perms.shotguned', compact('perms'));
}
}
51 changes: 51 additions & 0 deletions resources/views/dashboard/perms/shotguned.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@extends('layouts.dashboard')

@section('title')
Permanences que tu as prises
@endsection

@section('smalltitle')
Liste des permanences que tu as prises.
@endsection

@section('content')
<div class="callout callout-info">
<h4>Liste de tes permanences</h4>
</div>
<div class="box box-default">
<div class="box-body table-responsive no-padding">
<table class="table table-hover align-middle text-center">
<tbody>
<tr>
<th>Nom</th>
<th>Lieu</th>
<th>Date</th>
<th>Début</th>
<th>Fin</th>
<th>Permanenciers</th>
<th>Description</th>
<th>Points</th>
<th>Quitter</th>
</tr>
@foreach ($perms as $perm)
<tr class="align-middle">
<td>{{ $perm->type->name }}</td>
<td>{{ $perm->place }}</td>
<td>{{ date('j/n/y', $perm->start) }}</td>
<td>{{ date('G\\Hi', $perm->start) }}</td>
<td>{{ date('G\\Hi', $perm->end) }}</td>
<td>{{ $perm->permanenciers->count().'/'.$perm->nbr_permanenciers }}</td>
<td>{{ $perm->description }}</td>
<td>{{ $perm->type->points }}</td>
<td>
<form action="{{ url('dashboard/perm/unshotgun/'.$perm->id) }}" method="post">
<button class="btn btn-xl btn-danger" type="submit">Quitter</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endsection
3 changes: 2 additions & 1 deletion resources/views/layouts/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
<li><a href="{{ url('dashboard/perm') }}">Liste des permanences</a></li>
<li><a href="{{ url('dashboard/permType') }}">Types de permanences</a></li>
@endif
<li><a href="{{ url('dashboard/perm/shotgun') }}">Shotgun des permanences</a></li>
<li><a href="{{ route('dashboard.perm.shotgun') }}">Shotgun des permanences</a></li>
<li><a href="{{ route('dashboard.perm.shotgun.list') }}">Liste de tes perms</a></li>
</ul>
</li>
@if (Auth::user()->isAdmin())
Expand Down
3 changes: 2 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@

// Perm model's route (for all users)
Route::group(['middleware' => 'authorize:volunteer'], function () {
Route::get('/perm/shotgun', ['as' => 'perm.shotgun', 'uses' => 'Admin\PermController@shotgun']);
Route::get('/perm/shotgun', ['as' => 'dashboard.perm.shotgun', 'uses' => 'Admin\PermController@shotgun']);
Route::get('/perm/shotgun/list', ['as' => 'dashboard.perm.shotgun.list', 'uses' => 'Admin\PermController@shotgunedList']);
Route::post('/perm/shotgun/{id}', ['uses' => 'Admin\PermController@doShotgun']);
Route::post('/perm/unshotgun/{id}', ['uses' => 'Admin\PermController@doUnshotgun']);
});
Expand Down

0 comments on commit 6fe5740

Please sign in to comment.