commit af0a94fc70448266ee069cd0ef4b2952f18c1a9f
Author: Adam Mištera <amistera@students.zcu.cz>
Date:   Sat May 16 14:18:15 2020 +0200

    Issue #8050 @1h
    [+] Vytvoření artefaktů pro desktop
    [+] Napojení komponenty books
    [+] Úprava route

diff --git a/app/Http/Controllers/ArtefactController.php b/app/Http/Controllers/ArtefactController.php
index 3ce984a..b37dd98 100644
--- a/app/Http/Controllers/ArtefactController.php
+++ b/app/Http/Controllers/ArtefactController.php
@@ -12,6 +12,8 @@ use Illuminate\View\View;
 
 class ArtefactController extends Controller
 {
+    const ORDER_COLUMN = 'page';
+
     public function __construct()
     {
         $this->middleware('auth');
@@ -24,7 +26,20 @@ class ArtefactController extends Controller
      */
     public function default()
     {
-        $artefacts = Artefact::all();
+        $artefacts = Artefact::simplePaginate(1);
+        foreach($artefacts as $artefact)
+        {
+            $artefact['likes'] = Artefact::find($artefact->id)->users()->count();
+            $artefact['favourite'] = is_null(User::find(Auth::id())->likesArtefacts()->find($artefact->id)) ? false : true;
+            $metadata = Artefact::find($artefact->id)->metadata()->orderBy(self::ORDER_COLUMN)->get();
+
+            foreach ($metadata as $item)
+            {
+                $item['favourite'] = is_null(User::find(Auth::id())->likesMetadata()->find($item->id)) ? false : true;
+            }
+
+            $artefact['metadata'] = $metadata;
+        }
 
         return view('artefact.default', ['artefacts' => $artefacts]);
     }
diff --git a/resources/views/artefact/default.blade.php b/resources/views/artefact/default.blade.php
index ac565b8..800d804 100644
--- a/resources/views/artefact/default.blade.php
+++ b/resources/views/artefact/default.blade.php
@@ -9,46 +9,6 @@
 
 
 @section('content')
-    <div class="container">
-        <div class="jumbotron mt-5">
-            <div class="text-center">
-                <h1>Artefact list</h1>
-                <p>
-                    Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
-                    Mauris dolor felis, sagittis at, luctus sed, aliquam non, tellus.
-                    Fusce tellus odio, dapibus id fermentum quis, suscipit id erat.
-                    Morbi scelerisque luctus velit. Vivamus porttitor turpis ac leo.
-                    Morbi scelerisque luctus velit.
-                    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
-                </p>
-            </div>
-        </div>
-
-        @if (count($artefacts) === 0)
-            <div class="text-center">
-                <h2>Currently no artefacts available.</h2>
-            </div>
-        @else
-            @foreach ($artefacts as $artefact)
-                <div class="artefacts-area mb-5">
-                    <div class="card">
-                        <svg class="bd-placeholder-img card-img-top" width="100%" height="180" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Image cap"><title>Placeholder</title><rect width="100%" height="100%" fill="#868e96"></rect><text x="45%" y="50%" fill="#dee2e6" dy=".3em">Artefact image</text></svg>
-                        <div class="card-body">
-                            <h5 class="card-title"><a href="{{ url('/artefact/' . $artefact->id) }}">{{$artefact->name}}</a> - {{$artefact->author}}</h5>
-                            <h6 class="card-subtitle mb-2 text-muted">{{$artefact->year}}, {{$artefact->pages}} pages</h6>
-                            <p class="card-text">
-                                Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
-                                Mauris dolor felis, sagittis at, luctus sed, aliquam non, tellus.
-                                Fusce tellus odio, dapibus id fermentum quis, suscipit id erat.
-                                Morbi scelerisque luctus velit. Vivamus porttitor turpis ac leo.
-                                Morbi scelerisque luctus velit.
-                                Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
-                            </p>
-                        </div>
-                    </div>
-                </div>
-            @endforeach
-        @endif
-    </div>
-
+    @component('components/books', ['artefacts' => $artefacts])
+    @endcomponent
 @endsection
diff --git a/routes/web.php b/routes/web.php
index 7ba019c..00102df 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -17,8 +17,8 @@ Route::get('/', 'PagesController@index');
 
 Route::get('/artefact', 'ArtefactController@default');
 Route::get('/artefact/{id}', 'ArtefactController@view');
-Route::post('/artefact/like/{id}', 'ArtefactController@like');
-Route::post('/artefact/unlike/{id}', 'ArtefactController@unlike');
+Route::get('/artefact/like/{id}', 'ArtefactController@like');
+Route::get('/artefact/unlike/{id}', 'ArtefactController@unlike');
 Route::get('/category/{id}', 'ArtefactController@showCategory');
 Route::get('/detail/like/{id}', 'DetailsController@like');
 Route::get('/detail/unlike/{id}', 'DetailsController@unlike');
