commit
8763aa74fa
|
@ -2,7 +2,7 @@
|
|||
|
||||
Web application made with Symfony 4 and React using Docker.
|
||||
|
||||
The api server listen to port 3000 and the front app to port 8000.
|
||||
The api server listen to port 8000 and the front app to port 3000.
|
||||
|
||||
## The story
|
||||
|
||||
|
|
|
@ -12,11 +12,8 @@ namespace App\DataFixtures;
|
|||
|
||||
use App\Entity\Question;
|
||||
use App\Entity\Response;
|
||||
use App\Repository\ResponseRepository;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Common\DataFixtures\FixtureInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
class AppFixtures extends Fixture
|
||||
|
@ -38,6 +35,7 @@ class AppFixtures extends Fixture
|
|||
foreach ($this->getData() as $data) {
|
||||
$question = new Question();
|
||||
$question->setText($data['text']);
|
||||
$question->setSticker($this->getRandomSticker());
|
||||
$manager->persist($question);
|
||||
|
||||
foreach ($data['responses'] as $response) {
|
||||
|
@ -81,4 +79,20 @@ class AppFixtures extends Fixture
|
|||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function getStickersData()
|
||||
{
|
||||
return [
|
||||
'http://image.noelshack.com/fichiers/2017/30/4/1501188178-jesusbestreup.png',
|
||||
];
|
||||
}
|
||||
|
||||
private function getRandomSticker(): string
|
||||
{
|
||||
$stickers = $this->getStickersData();
|
||||
shuffle($stickers);
|
||||
$selectedSticker = array_slice($stickers, 0, 1);
|
||||
|
||||
return array_shift($selectedSticker);
|
||||
}
|
||||
}
|
|
@ -42,6 +42,11 @@ class Question
|
|||
*/
|
||||
private $responses;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $sticker;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->responses = new ArrayCollection();
|
||||
|
@ -119,4 +124,16 @@ class Question
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSticker(): ?string
|
||||
{
|
||||
return $this->sticker;
|
||||
}
|
||||
|
||||
public function setSticker(?string $sticker): self
|
||||
{
|
||||
$this->sticker = $sticker;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class QuestionType extends AbstractType
|
|||
{
|
||||
$builder
|
||||
->add('text')
|
||||
->add('date')
|
||||
->add('sticker')
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>{% block title %}Admin{% endblock %}</title>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>{{ block('title') }}</h1>
|
||||
|
||||
<div class="row">
|
||||
<div class="col col-12">
|
||||
<a href="{{ path('question_index') }}" class="btn btn-primary btn-xs">Questions</a>
|
||||
<a href="{{ path('response_index') }}" class="btn btn-primary btn-xs">Responses</a>
|
||||
</div>
|
||||
|
||||
<div class="col col-12" style="margin-top: 30px;">
|
||||
{% block body %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,13 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
<title>Edit Question</title>
|
||||
{% block title %}Edit question{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Edit Question</h1>
|
||||
|
||||
{{ include('question/_form.html.twig', {'button_label': 'Update'}) }}
|
||||
|
||||
<a href="{{ path('question_index') }}">back to list</a>
|
||||
|
||||
<hr>
|
||||
|
||||
{{ include('question/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
|
@ -1,10 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
<title>Question index</title>
|
||||
{% block title %}Question index{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Question index</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -33,5 +31,7 @@
|
|||
</tbody>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
<a href="{{ path('question_new') }}">Create new</a>
|
||||
{% endblock %}
|
|
@ -1,10 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
<title>New Question</title>
|
||||
{% block title %}Create new Question{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Create new Question</h1>
|
||||
|
||||
{{ include('question/_form.html.twig') }}
|
||||
|
||||
<a href="{{ path('question_index') }}">back to list</a>
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
<title>Question</title>
|
||||
{% block title %}Question{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Question</h1>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<td>{{ question.id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Sticker</th>
|
||||
<td><img src="{{ question.sticker }}" alt=""></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Text</th>
|
||||
<td>{{ question.text }}</td>
|
||||
|
@ -26,5 +28,7 @@
|
|||
|
||||
<a href="{{ path('question_edit', {'id': question.id}) }}">edit</a>
|
||||
|
||||
<hr>
|
||||
|
||||
{{ include('question/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
|
@ -1,13 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
<title>Edit Response</title>
|
||||
{% block title %}Edit Response{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Edit Response</h1>
|
||||
|
||||
{{ include('response/_form.html.twig', {'button_label': 'Update'}) }}
|
||||
|
||||
<a href="{{ path('response_index') }}">back to list</a>
|
||||
|
||||
<hr>
|
||||
|
||||
{{ include('response/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
|
@ -1,10 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
<title>Response index</title>
|
||||
{% block title %}Response index{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Response index</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
<title>New Response</title>
|
||||
{% block title %}New Response{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Create new Response</h1>
|
||||
|
||||
{{ include('response/_form.html.twig') }}
|
||||
|
||||
<a href="{{ path('response_index') }}">back to list</a>
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
<title>Response</title>
|
||||
{% block title %}Response{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Response</h1>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
|
@ -22,5 +20,7 @@
|
|||
|
||||
<a href="{{ path('response_edit', {'id': response.id}) }}">edit</a>
|
||||
|
||||
<hr>
|
||||
|
||||
{{ include('response/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
Loading…
Reference in New Issue