Laravel
Models Migration Relation
Introduction Installation Projet:Structure Strucutre,model,migration Migration,Models,Relation Artisan CLI Migrations:Exemples Models:Exemples Relations:Exemples 1 Relations:Exemples 2
Les Relations
BelongsTo HasOne HasMany BelongsToMany HasManyThrough
Exemples des Relations
Relations:oneToMany,ManyToMany... Relations:Exemples
Exercices
Exercice 1 Exercice 2
Controllers Views Routes
Routes,Controller,Model,view
Les Routes
Définir:Routes Routes avec Paramètres Routes nommées Groupes de routes
Les Controllers
Les Controllers Les Contrôleurs de Ressources
Les Vues
Vues et Blade Templates Blade Layouts et Sections Sous-vues Composants et Slots Contrôles de flux
MVC :CRUD
CRUD: Produit CRUD: Etudiant CRUD: Car CRUD,Recherche: Book
Validation
Exemple :Projets
ORM:Eloquent
Exemple :Transport
Api:Laravel +React
Middleware

Seeders & Factories
Exemples :EFM

Authenfication
TP:Schools Management
Authenfication:React
Layouts
Exercices





Gestions Projet: Views

AjouterProjet.blade
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="{{ asset('style.css') }}">
</head>
<body>
    <h1>Ajouter Projet</h1>
    <form action="{{ route("EnregistrerProjet") }}" method="post" enctype="multipart/form-data">
        @csrf
        <table>
            <tr>
                <td><label for="nomP">Nom Projet:</label></td>
                <td><input type="text" id="nomP" name="nomP"></td>
            </tr>
            @error('nomP')
            <tr>
                <td></td>
                <td><span class="error">{{ $message }}</span></td>
            </tr>
            @enderror

            <tr>
                <td><label for="description">Description:</label></td>
                <td><input type="text" id="description" name="description"></td>
            </tr>
            @error('description')
            <tr>
                <td></td>
                <td><span class="error">{{ $message }}</span></td>
            </tr>
            @enderror

            <tr>
                <td><label for="photoP">Photo:</label></td>
                <td><input type="file" id="photoP" name="photoP"></td>
            </tr>
            @error('photoP')
            <tr>
                <td></td>
                <td><span class="error">{{ $message }}</span></td>
            </tr>
            @enderror

            <tr>
                <td></td>
                <td><input type="submit" value="Ajouter"></td>
            </tr>

            @if(session('msg'))
            <tr>
                <td></td>
                <td><p>{{session('msg')}}</p></td>
            </tr>
            @endif
        </table>
    </form>
</body>
</html>


AfficherProjet.blade.php
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="{{ asset('style.css') }}">
</head>

<body>
    <h1>Liste des projets</h1>
    <table>
        <tr>
            <th>NomProjet</th>
            <th>Description</th>
            <th>Taches</th>
            <th>Image</th>
            <th>Action</th>
        </tr>
        @foreach ($projet as $p)
            <tr>
                <td>{{ $p->nomP }}</td>
                <td>{{ $p->description }}</td>
                <td>
                @foreach ($p->Tache as $t)
                    <ul>
                        <li>{{ $t->duree }}</li>
                    </ul>
                @endforeach
                </td>
                <td><img src="/{{ $p->photoP }}" alt="" style="width: 250px"></td>
                <td><a href="{{ route('ModifierProjet', ['idP' => $p->idP]) }}">Modifier</a>
                    <a href="{{ route('SupprimerProjet', ['idP' => $p->idP]) }}">Supprimer</a>
                </td>
            </tr>
        @endforeach
    </table>
</body>

</html>

ModifierProjet.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="{{ asset('style.css') }}">

</head>
<body>
    <h1>Modifier Projet {{ $projet->idP }}</h1>
    <form action="{{ route("MettreAJourProjet", ['idP' => $projet->idP]) }}" method="post">
        @method("PUT")
        @csrf
        <table>
            <tr>
                <td><label for="nomP">Nom Projet</label></td>
                <td><input type="text" id="nomP" value="{{ $projet->nomP }}" name="nomP"></td>
            </tr>
            <tr>
                <td><label for="description">Description</label></td>
                <td><input type="description" id="description" value="{{ $projet->description }}" name="description"></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="submit" value="Modifier"></td>
            </tr>
        </table>
    </form>
</body>
</html>

AjouterDeveloppeur.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="{{ asset('style.css') }}">
</head>
<body>
    <h1>Ajouter Developpeur</h1>
    <form action="{{ route("EnregistrerDeveloppeur") }}" method="post" enctype="multipart/form-data">
        @csrf
        <table>
            <tr>
                <td><label for="nomDev">Nom:</label></td>
                <td><input type="text" name="nomDev" id="nomDev"></td>
            </tr>
            @error('nomDev')
            <tr>
                <td></td>
                <td><span class="error">{{ $message }}</span></td>
            </tr>
            @enderror
            <tr>
                <td><label for="prenomDev">Prenom:</label></td>
                <td><input type="text" name="prenomDev" id="prenomDev"></td>
            </tr>
            @error('prenomDev')
            <tr>
                <td></td>
                <td><span class="error">{{ $message }}</span></td>
            </tr>
            @enderror
            <tr>
                <td><label for="cv">CV:</label></td>
                <td><input type="file" name="cv" id="cv"></td>
            </tr>
            @error('cv')
            <tr>
                <td></td>
                <td><span class="error">{{ $message }}</span></td>
            </tr>
            @enderror
            <tr>
                <td><label for="photoDev">Photo:</label></td>
                <td><input type="file" name="photoDev" id="photoDev"></td>
            </tr>
            @error('photoDev')
            <tr>
                <td></td>
                <td><span class="error">{{ $message }}</span></td>
            </tr>
            @enderror
            <tr>
                <td></td>
                <td><input type="submit" value="Ajouter"></td>
            </tr>
        </table>
        @if(session('msg'))
        <p>{{session('msg')}}</p>
        @endif
    </form>
</body>
</html>

AfficherInfoDev.blade.php
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="{{ asset('style.css') }}">
</head>

<body>
    <h1>Afficher les informations en relation avec le developpeur</h1>
    <form action="{{ route('ValiderAfficherInfoDev') }}" method="post">
        @csrf
        <label for="idDev">Nom developpeur: </label>
        <select name="idDev" id="idDev">
            <option value="#">Selectionner un developpeur</option>
            @foreach ($developpeurs as $d)
                <option value="{{ $d->idDev }}">{{ $d->nomDev }}</option>
            @endforeach
        </select>
        <input type="submit" value="OK">
    </form>
    @if (isset($nombreProjet))
        <table>
            <tr>
                <td>Nombre Projet: </td>
                <td>
                    {{ $nombreProjet->nbreP }}
                </td>
            </tr>
            <tr>
                <td>Nombre Taches: </td>
                <td>
                    {{ $nombreTache->nbreT }}
                </td>
            </tr>
            <tr>
                <td>Duree Totale: </td>
                <td>
                    {{ $dureeTotale->dureeT }}
                </td>
            </tr>
            <tr>
                <td>Duree Moyenne Par Tache: </td>
                <td>
                    {{ $dureeMoyenneParTache->moyenneT }}
                </td>
            </tr>
            <tr>
                <td>Duree Moyenne Par Projet: </td>
                <td>
                    {{ $dureeMoyenneParProjet->nomP }} - {{ $dureeMoyenneParProjet->moyenneP }}
                </td>
            </tr>
            <tr>
                <td>Projet plus chère: </td>
                <td>
                    {{ $projetPlusChere->nomP }} - {{ $projetPlusChere->maxC }}
                </td>
            </tr>
            <tr>
                <table>
                    <tr>
                        <th>Nom Projet</th>
                        <th>Duree Total</th>
                    </tr>
                @foreach ($projetAvecDureeTotale as $p)
                    <tr>
                        <td>{{ $p->nomP}}</td>
                        <td>{{ $p->dureeT }}</td>
                    </tr>
                @endforeach
                </table>
            </tr>
        </table>
    @endif

</body>

</html>

ModifierDeveloppeur.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="{{ asset('style.css') }}">
</head>
<body>
    <h1>Modifier developpeur {{ $developpeur->idDev }}</h1>
    <form action="{{ route("MettreAJourDeveloppeur", ["idDev"=>$developpeur->idDev]) }}" method="post">
        @csrf
        @method("PUT")
        <label for="nomDev">Nom developpeur</label>
        <input type="text" name="nomDev" id="nomDev" value="{{ $developpeur->nomDev }}"><br>
        <label for="prenomDev">Prenom developpeur</label>
        <input type="text" name="prenomDev" id="prenomDev" value="{{ $developpeur->prenomDev }}"><br>
        <input type="submit" value="Modifier">
    </form>
</body>
</html>

AjouterTache.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="{{ asset('style.css') }}">
</head>
<body>
    <h1>Ajouter tache</h1>
    <form action="{{ route('EnregistrerTache') }}" method="post">
        @csrf
        <table>
            <tr>
                <td>Nom de projet: </td>
                <td>
                    <select name="idP">
                        <option value="#">Select projet</option>
                        @foreach($projet as $p)
                            <option value="{{ $p->idP}}">{{ $p->nomP }}</option>
                        @endforeach
                    </select>
                </td>
            </tr>
            <tr>
                @error('idP')
                <td><span class="error">{{ $message }}</span></td>
                @enderror
            </tr>
            <tr>
                <td>Nom de Developpeur: </td>
                <td>
                    <select name="idDev">
                        <option value="#">Select Developpeur: </option>
                        @foreach($developpeur as $d)
                            <option value="{{$d->idDev}}">{{ $d->nomDev }}</option>
                        @endforeach
                    </select>
                </td>
            </tr>
            <tr>
                @error('idDev')
                <td><span class="error">{{ $message }}</span></td>
                @enderror
            </tr>

            <tr>
                <td>Duree: </td>
                <td><input type="number" name="duree"></td>
            </tr>
            <tr>
                @error('duree')
                <td><span class="error">{{ $message }}</span></td>
                @enderror
            </tr>
            <tr>
                <td>Cout d'heure: </td>
                <td><input type="number" name="coutHeure"></td>
            </tr>
            <tr>
                @error('coutHeure')
                <td><span class="error">{{ $message }}</span></td>
                @enderror
            </tr>
            <tr>
                <td>Etat: </td>
                <td><input type="text" name="etat"></td>
            </tr>
            <tr>
                @error('etat')
                <td><span class="error">{{ $message }}</span></td>
                @enderror
            </tr>
            <tr>
                <td colspan="2"><input type="submit" value="Ajouter Tache" ></td>
            </tr>
            @if(session('msg'))
            <tr>
                <td></td>
                <td><p>{{session('msg')}}</p></td>
            </tr>
            @endif
        </table>
    </form>
</body>
</html>

AfficherTache.blade
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="{{ asset('style.css') }}">
</head>
<body>
    <h1>Liste Taches</h1>
    <table>
        <tr>
            <th>Nom de Project</th>
            <th>Nom de Developpeur</th>
            <th>Duree</th>
            <th>Cout Heure</th>
            <th>Etat</th>
            <th>Action</th>
        </tr>
        @foreach($tache as $t)
            <tr>
                <td>{{ $t->projet->nomP }}</td>
                <td>{{ $t->developpeur->nomDev }}</td>
                <td>{{ $t->duree }}</td>
                <td>{{ $t->coutHeure }}</td>
                <td>{{ $t->etat }}</td>
                <td>
                    <a href="{{ route('ModifierTache', ['idT' => $t->idT]) }}">Modifier</a>
                    <a href="{{ route('SupprimerTache', ['idT' => $t->idT]) }}">Supprimer</a>
                </td>
            </tr>
        @endforeach
    </table>
</body>
</html>

ModifierTache.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="{{ asset('style.css') }}">
</head>
<body>
    <h1>Modifier Tache {{ $tache->idT }}</h1>
    <form action="{{ route('MettreAjourTache', ['idT' => $tache->idT]) }}" method="post">
        @csrf
        @method("PUT")
        <table>
            <tr>
                <td>Nom de projet: </td>
                <td>
                    <select name="idP">
                        <option value="#">Select projet</option>
                        @foreach($projet as $p)
                            <option value="{{ $p->idP}}">{{ $p->nomP }}</option>
                        @endforeach
                    </select>
                </td>
            </tr>
            </tr>
            <tr>
                <td>Nom de Developpeur: </td>
                <td>
                    <select name="idDev">
                        <option value="#">Select Developpeur: </option>
                        @foreach($developpeur as $d)
                            <option value="{{$d->idDev}}">{{ $d->nomDev }}</option>
                        @endforeach
                    </select>
                </td>
            </tr>
            <tr>
                <td>Duree: </td>
                <td><input type="number" name="duree" value="{{ $tache->duree }}"></td>
            </tr>
            </tr>
            <tr>
                <td>Cout d'heure: </td>
                <td><input type="number" name="coutHeure" value="{{ $tache->coutHeure }}"></td>
            </tr>
            <tr>
                <td>Etat: </td>
                <td><input type="text" name="etat" value="{{ $tache->etat }}"></td>
            </tr>

            </tr>
            <tr>
                <td colspan="2"><input type="submit" value="Modifier Tache" ></td>
            </tr>
            @if(session('msg'))
            <tr>
                <td></td>
                <td><p>{{session('msg')}}</p></td>
            </tr>
            @endif
        </table>
    </form>
</body>
</html>

AfficherProjetCout.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="{{ asset('style.css') }}">
</head>
<body>
    <h1>Liste des projets avec leurs coûts totaux</h1>
    <table>
        <tr>
            <th>Nom Projet</th>
            <th>Total cout projet</th>
        </tr>
        @foreach($projet as $p)
        <tr>
            <td>{{ $p->nomP }}</td>
            <td>{{ $p->totalCout }}</td>
        </tr>
        @endforeach
    </table>
</body>
</html>

RechercheParNomDeveloppeur.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="{{ asset('style.css') }}">
</head>
<body>
    <h1>Recherche par developpeur</h1>
    <form action="{{ route("ValiderRechercherParNomDev") }}" method="post">
        @csrf
        <table>
            <tr>
                <td><label for="nomDev">Nom Developpeur: </label></td>
                <td><select name="nomDev" id="nomDev">
                    @foreach ($developpeurs as $d)
                    <option value="{{ $d->nomDev }}">{{ $d->nomDev }}</option>
                    @endforeach
                </select></td>
            </tr>
        </table>
        <input type="submit" value="Ok">
    </form>
    @if (isset($developpeurSelectionner))
    <ul>
        <li>Nom Developpeur: {{ $developpeurSelectionner->nomDev }}</li>
        @foreach ($developpeurSelectionner->Tache as $t)
        <li>Cout heure: {{ $t->coutHeure }}</li>
        <li>Duree : {{ $t->duree }}</li>
        <li>Projet: {{ $t->Projet->nomP }}</li>
        @endforeach
    </ul>

    @endif
</body>
</html>

RechercherParProjet.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="{{ asset('style.css') }}">

</head>
<body>
    <h1>Recherche par projet</h1>
    <form action="{{ route("ValiderRechercher") }}" method="post">
        @csrf
        <table>
            <tr>
                <td><label for="nomP">Nom Projet</label></td>
                <td><input type="text" id="nomP" name="nomP"></td>
            </tr>
        </table>
        <input type="submit" value="Ok">
    </form>
    @if(isset($projets))
        @foreach ($projets as $p)
        <table>
            <tr>
                <th>Nom Projet</th>
                <th>Description</th>
                <th>Liste Taches</th>
            </tr>
            <tr>
                <td>{{ $p->nomP }}</td>
                <td>{{ $p->description }}</td>
                <td>
                    @foreach ($p->Tache as $t)
                        <ul>
                            <li>cout d'heure: {{ $t->coutHeure }}</li>
                            <li>duree: {{ $t->duree }}</li>
                        </ul>
                    @endforeach
                </td>
            </tr>
        </table>
    @endforeach
    @endif
</body>
</html>

RechercherParTache.blade.php
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="{{ asset('style.css') }}">
</head>
<body>
    <h1>Recherche par tache</h1>
    <form action="{{ route('ValiderRechercherParTache') }}" method="post">
        @csrf
        <table>
            <tr>
                <td><label for="idT">Id tache: </label></td>
                <td>
                    <select name="idT" id="idT">
                    @foreach ($tache as $t)
                        <option value="{{ $t->idT }}">{{ $t->idT }}</option>
                    @endforeach
                    </select></td>
            </tr>
        </table>
        <input type="submit" value="Ok">
    </form>
    @if (isset($tacheSelectionner))
        <ul>
            <li>Id Tache: {{ $tacheSelectionner->idT }}</li>
            <li>Nom Developpeur: {{ $tacheSelectionner->Developpeur->nomDev }}</li>
            <li>Nom Projet: {{ $tacheSelectionner->Projet->nomP }}</li>
        </ul>
    @endif
</body>

</html>