Skip to content

Commit

Permalink
Mostrando Posts Cadastrados aula 39
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian Pessanha da Silva committed Sep 28, 2021
1 parent e834735 commit f83ea4b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
7 changes: 6 additions & 1 deletion app/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
namespace App\Controllers;

use App\Controllers\Controller;
use App\Models\Post;

Class HomeController extends Controller
{
public function index($request, $response)
{
return $this->container->view->render($response, 'index.twig');
$data = [
'posts' => Post::all()
];

return $this->container->view->render($response, 'index.twig', $data);
}
}
14 changes: 10 additions & 4 deletions resources/views/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,30 @@
{% block content %}
<section class="articles">
<div class="column is-8 is-offset-2">
{% for post in posts %}
<div class="card article">
<div class="card-content">
<div class="media">
<div class="media-center">
<img src="{{ base_url() }}/uploads/{{ auth.user.avatar }}" alt="imagem do autor" class="author-image"/>
</div>
<div class="media-content has-text-centered">
<p class="title article-title"></p>
<div class="tags has-addons level-item">
<span class="tag is-rounded"></span>
</div>
<p class="title article-title">{{ post.title | title }}</p>
<p class="subtitle is-6 article-subtitle">
<span class="">{{ post.created_at | date('d/m/Y H:i:s') }}</span>
</p>
</div>
</div>
<div class="content article-body">
{{ post.description | raw }}
</div>
<div class="has-text-right">
<a href="" class="button is-warning is-focused">Editar</a>
<a href="" class="button is-danger is-focused">Deletar</a>
</div>
</div>
</div>
{% endfor %}

<section class="hero is-info is-bold is-small promo-block">
<div class="hero-body">
Expand Down

0 comments on commit f83ea4b

Please sign in to comment.