commit
8763aa74fa
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Web application made with Symfony 4 and React using Docker.
|
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
|
## The story
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,8 @@ namespace App\DataFixtures;
|
||||||
|
|
||||||
use App\Entity\Question;
|
use App\Entity\Question;
|
||||||
use App\Entity\Response;
|
use App\Entity\Response;
|
||||||
use App\Repository\ResponseRepository;
|
|
||||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Common\Persistence\ObjectManager;
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
use Doctrine\Common\DataFixtures\FixtureInterface;
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
|
||||||
class AppFixtures extends Fixture
|
class AppFixtures extends Fixture
|
||||||
|
@ -38,6 +35,7 @@ class AppFixtures extends Fixture
|
||||||
foreach ($this->getData() as $data) {
|
foreach ($this->getData() as $data) {
|
||||||
$question = new Question();
|
$question = new Question();
|
||||||
$question->setText($data['text']);
|
$question->setText($data['text']);
|
||||||
|
$question->setSticker($this->getRandomSticker());
|
||||||
$manager->persist($question);
|
$manager->persist($question);
|
||||||
|
|
||||||
foreach ($data['responses'] as $response) {
|
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;
|
private $responses;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
|
*/
|
||||||
|
private $sticker;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->responses = new ArrayCollection();
|
$this->responses = new ArrayCollection();
|
||||||
|
@ -119,4 +124,16 @@ class Question
|
||||||
|
|
||||||
return $this;
|
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
|
$builder
|
||||||
->add('text')
|
->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 %}
|
{% block body %}
|
||||||
<h1>Edit Question</h1>
|
|
||||||
|
|
||||||
{{ include('question/_form.html.twig', {'button_label': 'Update'}) }}
|
{{ include('question/_form.html.twig', {'button_label': 'Update'}) }}
|
||||||
|
|
||||||
<a href="{{ path('question_index') }}">back to list</a>
|
<a href="{{ path('question_index') }}">back to list</a>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
{{ include('question/_delete_form.html.twig') }}
|
{{ include('question/_delete_form.html.twig') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,10 +1,8 @@
|
||||||
<!DOCTYPE html>
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
<title>Question index</title>
|
{% block title %}Question index{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1>Question index</h1>
|
|
||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -33,5 +31,7 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
<a href="{{ path('question_new') }}">Create new</a>
|
<a href="{{ path('question_new') }}">Create new</a>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,10 +1,8 @@
|
||||||
<!DOCTYPE html>
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
<title>New Question</title>
|
{% block title %}Create new Question{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1>Create new Question</h1>
|
|
||||||
|
|
||||||
{{ include('question/_form.html.twig') }}
|
{{ include('question/_form.html.twig') }}
|
||||||
|
|
||||||
<a href="{{ path('question_index') }}">back to list</a>
|
<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 %}
|
{% block body %}
|
||||||
<h1>Question</h1>
|
|
||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Id</th>
|
<th>Id</th>
|
||||||
<td>{{ question.id }}</td>
|
<td>{{ question.id }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Sticker</th>
|
||||||
|
<td><img src="{{ question.sticker }}" alt=""></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Text</th>
|
<th>Text</th>
|
||||||
<td>{{ question.text }}</td>
|
<td>{{ question.text }}</td>
|
||||||
|
@ -26,5 +28,7 @@
|
||||||
|
|
||||||
<a href="{{ path('question_edit', {'id': question.id}) }}">edit</a>
|
<a href="{{ path('question_edit', {'id': question.id}) }}">edit</a>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
{{ include('question/_delete_form.html.twig') }}
|
{{ include('question/_delete_form.html.twig') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,13 +1,13 @@
|
||||||
<!DOCTYPE html>
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
<title>Edit Response</title>
|
{% block title %}Edit Response{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1>Edit Response</h1>
|
|
||||||
|
|
||||||
{{ include('response/_form.html.twig', {'button_label': 'Update'}) }}
|
{{ include('response/_form.html.twig', {'button_label': 'Update'}) }}
|
||||||
|
|
||||||
<a href="{{ path('response_index') }}">back to list</a>
|
<a href="{{ path('response_index') }}">back to list</a>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
{{ include('response/_delete_form.html.twig') }}
|
{{ include('response/_delete_form.html.twig') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,10 +1,8 @@
|
||||||
<!DOCTYPE html>
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
<title>Response index</title>
|
{% block title %}Response index{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1>Response index</h1>
|
|
||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
<!DOCTYPE html>
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
<title>New Response</title>
|
{% block title %}New Response{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1>Create new Response</h1>
|
|
||||||
|
|
||||||
{{ include('response/_form.html.twig') }}
|
{{ include('response/_form.html.twig') }}
|
||||||
|
|
||||||
<a href="{{ path('response_index') }}">back to list</a>
|
<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 %}
|
{% block body %}
|
||||||
<h1>Response</h1>
|
|
||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -22,5 +20,7 @@
|
||||||
|
|
||||||
<a href="{{ path('response_edit', {'id': response.id}) }}">edit</a>
|
<a href="{{ path('response_edit', {'id': response.id}) }}">edit</a>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
{{ include('response/_delete_form.html.twig') }}
|
{{ include('response/_delete_form.html.twig') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in New Issue