Displaying files attached to a book.

This commit is contained in:
krzysiej
2022-05-23 15:35:24 +02:00
parent dddd432e3b
commit 319f6311fc
3 changed files with 53 additions and 26 deletions

View File

@@ -44,7 +44,6 @@ class BookController extends AbstractController
$ebook = $request->files->get('book')['ebook']; $ebook = $request->files->get('book')['ebook'];
if ($ebook) { if ($ebook) {
dd($ebook);
$ebook->move( $ebook->move(
$this->getParameter('book_files'), $this->getParameter('book_files'),
'ebook_' . $book->getId() . '.' . $ebook->guessClientExtension() 'ebook_' . $book->getId() . '.' . $ebook->guessClientExtension()

View File

@@ -21,7 +21,7 @@
<tbody> <tbody>
{% for book in books %} {% for book in books %}
<tr> <tr>
<td>{% if file_exists(asset('book_covers/cover_' ~ book.id ~ '.jpg')) %}<img class="img-thumbnail" src="{{ asset('book_covers/cover_' ~ book.id ~ '.jpg' ) }}" /> {% endif %}</td> <td>{% if file_exists(asset('book_covers/cover_' ~ book.id ~ '.jpg')) %}<img class="img-thumbnail" style="max-width: 80px" src="{{ asset('book_covers/cover_' ~ book.id ~ '.jpg' ) }}" /> {% endif %}</td>
<td>{{ book.id }}</td> <td>{{ book.id }}</td>
<td>{{ book.Title }}</td> <td>{{ book.Title }}</td>
<td>{{ book.language }}</td> <td>{{ book.language }}</td>

View File

@@ -7,33 +7,61 @@
<table class="table"> <table class="table">
<tbody> <tbody>
<tr> <tr>
<th>Id</th> <th>Id</th>
<td>{{ book.id }}</td> <td>{{ book.id }}</td>
</tr> </tr>
<tr> <tr>
<th>Title</th> <th>Title</th>
<td>{{ book.Title }}</td> <td>{{ book.Title }}</td>
</tr> </tr>
<tr> <tr>
<th>Language</th> <th>Language</th>
<td>{{ book.language }}</td> <td>{{ book.language }}</td>
</tr> </tr>
<tr> <tr>
<th>Description</th> <th>Description</th>
<td>{{ book.description }}</td> <td>{{ book.description }}</td>
</tr> </tr>
<tr> <tr>
<th>Publisher</th> <th>Publisher</th>
<td>{{ book.publisher }}</td> <td>{{ book.publisher }}</td>
</tr> </tr>
<tr> <tr>
<th>Publish_date</th> <th>Publish_date</th>
<td>{{ book.publishDate ? book.publishDate|date('Y-m-d') : '' }}</td> <td>{{ book.publishDate ? book.publishDate|date('Y-m-d') : '' }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>File name</th>
<th>File size</th>
<th>Extension</th>
<th>Download</th>
<th>Remove</th>
</tr>
</thead>
<tbody>
{% for file in book.files %}
<tr>
<td>{{ file.id }}</td>
<td>{{ file.fileName }}</td>
<td>{{ file.fileSize }}</td>
<td>{{ file.extension }}</td>
<td>download</td>
<td>remove</td>
</tr>
{% else %}
<tr>
<td colspan="6">no files found</td>
</tr>
{% endfor %}
</table>
<a href="{{ path('app_book_index') }}">back to list</a> <a href="{{ path('app_book_index') }}">back to list</a>
<a href="{{ path('app_book_edit', {'id': book.id}) }}">edit</a> <a href="{{ path('app_book_edit', {'id': book.id}) }}">edit</a>