Commit 200c5b8b authored by quentin.vrel's avatar quentin.vrel

Fin du projet Laravel

parent 5e4bf219
......@@ -39,9 +39,9 @@ class migrationOrder extends Command
{
$migrations = [
'2014_10_12_000000_create_users_table.php',
// '2014_10_12_100000_create_password_resets_table.php',
'2014_10_12_100000_create_password_resets_table.php',
// '2014_10_12_200000_add_two_factor_columns_to_users_table.php',
// '2019_08_19_000000_create_failed_jobs_table.php',
'2019_08_19_000000_create_failed_jobs_table.php',
// '2019_12_14_000001_create_personal_access_tokens_table.php',
// '2020_11_12_102755_create_sessions_table.php',
'2020_11_24_144826_create_category_table.php',
......
......@@ -6,9 +6,10 @@ use Illuminate\Database\Eloquent\Model;
class Game extends Model
{
protected $connection = 'mysql';
protected $table = 'game';
protected $primaryKey = 'gamer_id';
protected $primaryKey = 'id_game';
public $incrementing = true;
public $timestamps = false;
......
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
return view('home');
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class MonControleur extends Controller
{
public function index() {
return view('MaVue');
}
}
......@@ -4,16 +4,44 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Game;
use App\Tournament;
class TournamentController extends Controller
{
public function index() {
$games = Game::all();
return view('create-tournament', ['games' => $games]);
public function index($args = []) {
$games = Game::select('titre', 'id_game')->get();
$args['games']=$games;
return view('create-tournament', $args);
}
public function createTournament(){
public function createTournament(Request $request){
$tournament = new Tournament();
$tournament->description=$request->input('description');
$year= $request->input('year-begin');
$month= $request->input('month-begin');
$day= $request->input('day-begin');
$tournament->tournament_date=$year . '-' . $month . '-' . $day;
$tournament->id_game=$request->input('select-game');
$tournament->created_at=date('Y-m-d');
try {
$tournament->save();
} catch (Exception $e) {
return $this->index(['post'=>false]);
}
return $this->index(['post'=>true]);
}
public function displayTournaments(){
$tournaments=Tournament::select('description','tournament_date','id_game')->get();
$games = Game::select('id_game','titre')->get();
$gamesTitles = [];
foreach ($games as $game) {
$gamesTitles[$game->id_game]=$game->titre;
}
foreach ($tournaments as $tournament) {
$tournament->titre=$gamesTitles[$tournament->id_game];
}
return view('home', ['tournaments'=>$tournaments]);
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Tournament extends Model
{
protected $connection = 'mysql';
protected $table = 'tournament';
protected $primaryKey = 'id_tournament';
public $incrementing = true;
public $timestamps = false;
}
This diff is collapsed.
......@@ -7,6 +7,10 @@ use Faker\Generator as Faker;
$factory->define(Game::class, function (Faker $faker) {
return [
//
'titre' => $faker->name,
'version' => $faker->unique()->randomDigit,
'created_at' => now(),
'updated_at' => now(),
'id_category' => 0
];
});
<?php
use Illuminate\Database\Seeder;
use App\Game;
class GameTableSeeder extends Seeder
{
......@@ -9,11 +10,16 @@ class GameTableSeeder extends Seeder
*
* @return void
*/
/*
public function run()
{
DB::table('game')->insert([
'created_at' => date("Y-m-d H:i:s"),
'updated_at' => date("Y-m-d H:i:s"),
]);
}*/
public function run()
{
factory(Game::class, 10)->create();
}
}
......@@ -4,7 +4,7 @@
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card text-white bg-dark">
<div class="card-header">{{ __('Login') }}</div>
<div class="card-body">
......
......@@ -4,7 +4,7 @@
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card text-white bg-dark">
<div class="card-header">{{ __('Register') }}</div>
<div class="card-body">
......
@extends('layouts.app')
@section('content')
@auth
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
@if (isset($post))
@if($post)
<div class="alert alert-success" role="alert">
Le tournoi a été créé.
</div>
$else
<div class="alert alert-danger" role="alert">
Un erreur est intervenue, merci de réessayer.
</div>
@endif
@endif
<div class="card text-white bg-dark">
@if (isset($post))
@if($post)
<div class="alert alert-success" role="alert">
Le tournoi a été créé.
</div>
@else
<div class="alert alert-danger" role="alert">
Un erreur est intervenue, merci de réessayer.
</div>
@endif
@endif
<div class="card-header">Créer un tournoi</div>
<div class="card-body">
<form method="POST" action="/form">
<form method="POST" action="{{ route('createTournament') }}">
@csrf
<div class="form-group row">
<label for="select-game" class="col-md-4 col-form-label text-md-right">Choisissez un jeu</label>
<div class="col-md-6">
<select name="select-game" id="select-game" class="custom-select" required autofocus>
@foreach ($games as $game)
<option value="{{ $game->id_game }}">{{ $game->id_game }}</option>
@endforeach
</select>
</div>
</div>
<div class="form-group row">
<label for="tournament-name" class="col-md-4 col-form-label text-md-right">Nom du tournoi</label>
<label for="description" class="col-md-4 col-form-label text-md-right">Nom du tournoi</label>
<div class="col-md-6">
<input name="tournament-name" id="tournament-name" type="text" class="form-control" required>
<input name="description" id="description" type="text" class="form-control" required autofocus>
</div>
<div class="invalid-feedback">
Veuillez saisir un nom.
......@@ -41,50 +33,35 @@
</div>
<div class="form-group row">
<label for="date-begin" class="col-md-4 col-form-label text-md-right">Date du début du tournoi</label>
<div class="col-md-6 row pr-0" name="date-begin" id="date-begin">
<div class="col-md-3">
<select name="day-begin" id="day-begin" class="custom-select" required autofocus>
@for ($i = 1; $i < 32; $i++)
<option value="{{ $i }}">{{ $i }}</option>
@endfor
</select>
</div>
<div class="col-md-5">
<select name="month-begin" id="month-begin" class="custom-select" required autofocus>
@for ($i = 1; $i < 13; $i++)
<option value="{{ $i }}">{{ date('F', mktime(0,0,0,$i) ) }}</option>
@endfor
</select>
</div>
<div class="col-md-4">
<select name="day-begin" id="day-begin" class="custom-select" required autofocus>
@for ($i = date('Y'); $i < date('Y') + 20; $i++)
<option value="{{ $i }}">{{ $i }}</option>
@endfor
</select>
</div>
<label for="select-game" class="col-md-4 col-form-label text-md-right">Choisissez un jeu</label>
<div class="col-md-6">
<select name="select-game" id="select-game" class="custom-select" required>
@foreach ($games as $game)
<option value="{{ $game->id_game }}">{{ $game->titre }}</option>
@endforeach
</select>
</div>
</div>
<div class="form-group row">
<label for="date-end" class="col-md-4 col-form-label text-md-right">Date du fin du tournoi</label>
<div class="col-md-6 row pr-0" name="date-end" id="date-end">
<label for="date-begin" class="col-md-4 col-form-label text-md-right">Date du début du tournoi</label>
<div class="col-md-6 row pr-0" name="date-begin" id="date-begin">
<div class="col-md-3">
<select name="day-end" id="day-end" class="custom-select" required autofocus>
<select name="day-begin" id="day-begin" class="custom-select" required autofocus>
@for ($i = 1; $i < 32; $i++)
<option value="{{ $i }}">{{ $i }}</option>
@endfor
</select>
</div>
<div class="col-md-5">
<select name="month-end" id="month-end" class="custom-select" required autofocus>
<select name="month-begin" id="month-begin" class="custom-select" required>
@for ($i = 1; $i < 13; $i++)
<option value="{{ $i }}">{{ date('F', mktime(0,0,0,$i) ) }}</option>
@endfor
</select>
</div>
<div class="col-md-4">
<select name="day-end" id="day-end" class="custom-select" required autofocus>
<select name="year-begin" id="year-begin" class="custom-select" required>
@for ($i = date('Y'); $i < date('Y') + 20; $i++)
<option value="{{ $i }}">{{ $i }}</option>
@endfor
......@@ -92,9 +69,10 @@
</div>
</div>
</div>
<div class="form-group row">
<button class="btn btn-primary mx-auto" type="submit">Submit form</button>
<button class="btn btn-primary mx-auto" type="submit">Enregistrer le tournoi</button>
</div>
</form>
......@@ -104,4 +82,16 @@
</div>
</div>
</div>
@else
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="alert alert-danger" role="alert">
Vous devez être connecté pour accéder à cette page.
</div>
</div>
</div>
</div>
@endauth
@endsection
......@@ -4,18 +4,30 @@
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@if (isset($tournaments) && !empty($tournaments))
<table class="table table-dark">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Nom</th>
<th scope="col">Jeu</th>
<th scope="col">Date</th>
</tr>
</thead>
<tbody>
@foreach($tournaments as $tournament)
<tr>
<th scope="row">{{$tournament->id_tournament}}</th>
<td>{{$tournament->description}}</td>
<td>{{$tournament->titre}}</td>
<td>{{$tournament->tournament_date}}</td>
</tr>
@endforeach
</tbody>
</table>
@endif
Bienvenue sur ma page d'accueil.
</div>
</div>
</div>
</div>
</div>
......
......@@ -19,9 +19,9 @@
<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>
<body class="bg-secondary">
<div id="app">
<nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
<nav class="navbar navbar-expand-md navbar-dark bg-dark shadow-sm">
<div class="container">
<a class="navbar-brand" href="{{ url('/') }}">
{{ config('app.name', 'Laravel') }}
......@@ -32,12 +32,13 @@
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<!-- Left Side Of Navbar -->
@auth
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="{{ url('/form') }}">{{ __('Créer un tournoi') }}</a>
</li>
</ul>
@endauth
<!-- Right Side Of Navbar -->
<ul class="navbar-nav ml-auto">
<!-- Authentication Links -->
......
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@200;600&display=swap" rel="stylesheet">
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>
<header>
<h1>@yield('Title')</h1>
</header>
<div id="page">
<article>
<p>@yield('content')</p>
</article>
</div>
<footer>
<p>Powered by <a href="https://laravel.com/">Laravel</a></p>
</footer>
</body>
</html>
@extends('layouts.app')
@section('Title', 'Page Title')
@section('content')
Du texte test.
@stop
\ No newline at end of file
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@200;600&display=swap" rel="stylesheet">
<!-- Styles -->
<style>
html, body {
background-color: #fff;
color: #636b6f;
font-family: 'Nunito', sans-serif;
font-weight: 200;
height: 100vh;
margin: 0;
}
.full-height {
height: 100vh;
}
.flex-center {
align-items: center;
display: flex;
justify-content: center;
}
.position-ref {
position: relative;
}
.top-right {
position: absolute;
right: 10px;
top: 18px;
}
.content {
text-align: center;
}
.title {
font-size: 84px;
}
.links > a {
color: #636b6f;
padding: 0 25px;
font-size: 13px;
font-weight: 600;
letter-spacing: .1rem;
text-decoration: none;
text-transform: uppercase;
}
.m-b-md {
margin-bottom: 30px;
}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
@if (Route::has('login'))
<div class="top-right links">
@auth
<a href="{{ url('/home') }}">Home</a>
@else
<a href="{{ route('login') }}">Login</a>
@if (Route::has('register'))
<a href="{{ route('register') }}">Register</a>
@endif
@endauth
</div>
@endif
<div class="content">
<div class="title m-b-md">
Laravel
</div>
<div class="links">
<a href="https://laravel.com/docs">Docs</a>
<a href="https://laracasts.com">Laracasts</a>
<a href="https://laravel-news.com">News</a>
<a href="https://blog.laravel.com">Blog</a>
<a href="https://nova.laravel.com">Nova</a>
<a href="https://forge.laravel.com">Forge</a>
<a href="https://vapor.laravel.com">Vapor</a>
<a href="https://github.com/laravel/laravel">GitHub</a>
</div>
</div>
</div>
</body>
</html>
......@@ -13,22 +13,16 @@ use Illuminate\Support\Facades\Route;
|
*/
Route::get('/', function () {
return view('home');
});
/*
Route::get('/vue2', 'MonControleur@index');
Route::get('/{firstname}/{name}', function ($firstname, $name) {
return "Koukou $firstname $name";
Route::get('/', 'TournamentController@displayTournaments');
Route::get('/home', function () {
return redirect('/');
});
*/
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::get('/form', 'TournamentController@index');
//Routes de test
Route::get('/formtest', 'TournamentController@createTournament');
Route::post('/form', 'TournamentController@createTournament')->name('createTournament');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment