31 lines
1.2 KiB
PHP
31 lines
1.2 KiB
PHP
<main>
|
|
<form action="/api/articles" method="POST">
|
|
@csrf
|
|
<label for="titre">Titre:</label>
|
|
<input type="text" name="titre" id="titre" required><br>
|
|
|
|
<label for="contenu">Contenu:</label>
|
|
<textarea name="contenu" id="contenu" required></textarea><br>
|
|
|
|
<button type="submit">Créer un Article</button>
|
|
</form>
|
|
<h1>Articles :</h1>
|
|
@if(!empty($articles) && count($articles) > 0)
|
|
@foreach($articles as $article)
|
|
<div class="article">
|
|
<h2>{{ $article['titre'] }}</h2>
|
|
<p class="date">Publié le {{ \Carbon\Carbon::parse($article['created_at'])->format('d/m/Y à H:i') }}</p>
|
|
<p>{{ $article['contenu'] }}</p>
|
|
<form action="/api/articles/{{ $article['id'] }}" method="POST" style="display:inline;">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit">Supprimer l'Article</button>
|
|
</form>
|
|
</div>
|
|
@endforeach
|
|
@else
|
|
<p>Aucun article disponible.</p>
|
|
@endif
|
|
</div>
|
|
</main>
|