Skip to content

Commit

Permalink
Merge branch 'PaulFront' into PYFront
Browse files Browse the repository at this point in the history
  • Loading branch information
PYDeret committed Jul 14, 2018
2 parents 1e6c3ca + 47c42c3 commit ece1e24
Show file tree
Hide file tree
Showing 9 changed files with 281 additions and 18 deletions.
58 changes: 58 additions & 0 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers;

use App\Equipe;
use Illuminate\Support\Facades\Auth;
use App\User;
use Illuminate\Http\Request;
Expand Down Expand Up @@ -144,6 +145,48 @@ public function updateLeague()
}


public function mesEquipes(User $user){

$user = Auth::user();


$mesEquipes = new \stdClass();


$mesEquipes->myteams = $this->getMyteams($user->id);
$mesEquipes->tournoisplay = $this->getTournois($user->id);


return view('users.gestion_equipes', compact('mesEquipes','user'));

}


public function DeleteEquipe(Request $request){

$id = $request->input('id');


DB::table('equipes_users')->where('equipes_users.equipe_id', '=', $id)->delete();

DB::table('equipes')->where('equipes.id', '=', $id)->delete();

$user = Auth::user();


$mesEquipes = new \stdClass();


$mesEquipes->myteams = $this->getMyteams($user->id);


return view('users.gestion_equipes', compact('mesEquipes','user'));


}



public function statistiques(User $user){

$user = Auth::user();
Expand All @@ -161,6 +204,21 @@ public function statistiques(User $user){
}



public function getMyteams($id){

$myteams = DB::table('equipes')->select('equipes.id','equipes.libelle','equipes.description','equipes.userId','equipes.created_at','equipes.updated_at')
->join("equipes_users", "equipes_users.equipe_id", "=", "equipes.id", 'left')
->join("users", "users.id", "=", "equipes_users.user_id", 'left')
->where('equipes.userId', '=', $id)
->distinct()
->get();

return $myteams;

}


public function getTournois($id){

$tournois = DB::table('tournois')->select('tournois.id','tournois.libelle','tournois.description','tournois.image', 'tournois.EquipeWin_id','tournois.DateDebut','tournois.DateFin','tournois.HeureDebut','tournois.HeureFin','tournois.created_at','tournois.updated_at')
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions resources/views/layouts/header_profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="youplay-user-navigation">
<div class="container">
<ul>
<li <?php if (strpos(url()->current(), 'profile') == false && strpos(url()->current(), 'messages') == false) {
<li <?php if (strpos(url()->current(), 'profile') == false && strpos(url()->current(), 'messages') == false && strpos(url()->current(), 'statistiques') == false && strpos(url()->current(), 'gestion_equipes') == false) {
echo 'class="active"';
}?>>
<a href="{{ route('users.edit', Auth::user()->id ) }}">Dernières activités</a>
Expand All @@ -26,7 +26,11 @@
}?>>
<a href="{{ route('users.statistiques', Auth::user()->id ) }}">Statistiques</a>
</li>

<li <?php if (strpos(url()->current(), 'gestion_equipes') !== false) {
echo 'class="active"';
}?>>
<a href="{{ route('users.gestion_equipes', Auth::user()->id ) }}">Gestion de mes equipes</a>
</li>


<?php endif; ?>
Expand Down
182 changes: 182 additions & 0 deletions resources/views/users/gestion_equipes.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
@include('layouts.header')
<section class="content-wrap">

@include('layouts.header_profile')

<div class="container youplay-content">

<div class="row">

<div class="col-md-9">

<h3>Mes equipes (<?php echo count($mesEquipes->myteams);?>):</h3>
<table class="table table-striped">
<tbody>
<tr>
<th>
Nom
</th>
<th>
Description
</th>
<th>
Autres membres
</th>
<th>
Tournois joués
</th>
<th>
Tournois remportés
</th>
<th style="text-align: center">
Horaires
</th>
<th>
Action
</th>
</tr>
<?php
$users = App\User::all();
?>
@foreach ($mesEquipes->myteams as $key => $value)

<tr>

<td id="libstats">
<p> {{ $value->libelle }}</p>
<?php
if($value->userId == Auth::user()->id){
?>
<span class="badge badge-pill" style="background-color:#d91d1f; ">Chef d'équipe</span>
<?php
}
?>
</td>

<td id="descstats">
<p>{!! $value->description !!}</p>

</td>

<td>
<?php
$users = App\User::all();
$equipes_users =App\EquipesUsers::all();
?>
@foreach($equipes_users as $equipes_user)
@foreach($users as $user)
<?php
if ($equipes_user->equipe_id == $value->id && $equipes_user->user_id == $user->id && $equipes_user->user_id != Auth::user()->id)
{
?>


<p><img src="{{ Voyager::image( $user->avatar ) }}" id="avataruser" alt="avatar"> {{$user->name}} </p>



<?php } ?>
@endforeach
@endforeach
</td>
<td>
<?php
$tournois = App\Tournoi::all();
$tournois_equipes =App\TournoisEquipe::all();
?>
@foreach($tournois_equipes as $tournois_equipe)
@foreach($tournois as $tournoi)
<?php
if ($tournois_equipe->EquipeId == $value->id && $tournois_equipe->TournoiId == $tournoi->id)
{
?>
<p><img src="{{ Voyager::image( $tournoi->image ) }}" id="avataruser" alt="avatar"> {{$tournoi->libelle}} </p>

<?php } ?>
@endforeach
@endforeach


</td>
<td>
@foreach ($mesEquipes->tournoisplay as $key => $values)
@if( $values->EquipeWin_id == $value->id )


<p><img src="{{ Voyager::image( $values->image ) }}" id="avataruser" alt="avatar"> {{$values->libelle}}


@endif
@endforeach

</td>
<td id="date">
<p><span id="customdate" class="date pull-left"><i class="fa fa-calendar"></i>{{ $value->created_at }} </span>

</td>
<td>

<form method="POST" id="deleteEquipe" action="{{ route('users.deleteEquipe') }}">


{{ csrf_field() }}

<input type="hidden" name="id" class="form-control" value="{{$value->id}}">

</form>
<a type=“submit” class="btn btn-sm btn-default" onclick="event.preventDefault();
document.getElementById('deleteEquipe').submit();"> Supprimer </a>

</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</section>
@include('layouts.footer')


<script>
$(function () {
$('#counter').html($('#count').val());
});
</script>

<style>
#libstats{
min-width: 21%;
}
#descstats{
min-width: 38%;
}
#date{
width: 25%;
}
#avataruser{
max-width: 40px;
padding: 5px;
}
#customdate{
margin-left: 10%;
}
</style>
Loading

0 comments on commit ece1e24

Please sign in to comment.