commit 3ce212351754e89ac8afcca527efe76eb034e283
Author: zabran <zabran@students.zcu.cz>
Date:   Wed May 27 16:10:08 2020 +0200

    Pokud o paginaci výbrané knihy z charts.

diff --git a/app/Http/Controllers/ArtefactController.php b/app/Http/Controllers/ArtefactController.php
index 73ba1ba..658c30f 100644
--- a/app/Http/Controllers/ArtefactController.php
+++ b/app/Http/Controllers/ArtefactController.php
@@ -117,13 +117,13 @@ class ArtefactController extends Controller
      * @param $id int id of the artefact
      * @return Factory|View
      */
-    public function view($id)
+    /*public function view($id)
     {
         $artefact = Artefact::find($id)->simplePaginate(1);
         $artefact = $this->prepData($artefact);
         //return view('artefact.view', ['artefact' => $artefact]);
         return view('artefact.default', ['artefacts' => $artefact]);
-    }
+    }*/
 
     /**
      * Likes artefact given by its id.
@@ -156,4 +156,44 @@ class ArtefactController extends Controller
 
         return back()->withInput();
     }
+
+    /**
+     * Returns artefact given by its id.
+     *
+     * @param $id int id of artefact
+     * @return RedirectResponse
+     */
+    public function view($id)
+    {
+        //$user = User::find(Auth::id());
+        //$artefact = Artefact::find($id);
+
+        $artefacts = Artefact::withCount('users')->orderByDesc('users_count')->get()->take(10);
+
+        $currentPage = -1; // You can set this to any page you want to paginate to
+
+        for($i=0;$i<10;$i++){
+            if($artefacts[$i]->id==$id) $currentPage = $i+1;
+        }
+
+        // Make sure that you call the static method currentPageResolver()
+        // before querying users
+        \Illuminate\Pagination\Paginator::currentPageResolver(function () use ($currentPage) {
+            return $currentPage;
+        });
+
+        $artefacts = Artefact::withCount('users')->orderByDesc('users_count')->limit(10)->paginate(1);
+
+        $artefacts = ArtefactController::prepData($artefacts);
+        return view('artefact.default', ['artefacts' => $artefacts]);
+        /*foreach($artefacts as $item)
+        {
+            $id = $item->id;
+            $item['likes'] = Artefact::find($id)->users()->count();
+            $item['favourite'] = is_null(User::find(Auth::id())->likesArtefacts()->find($id)) ? false : true;
+        }*/
+
+
+        //return back()->withInput();
+    }
 }
diff --git a/resources/views/charts/index.blade.php b/resources/views/charts/index.blade.php
index 5484cb9..1b3050d 100644
--- a/resources/views/charts/index.blade.php
+++ b/resources/views/charts/index.blade.php
@@ -15,7 +15,7 @@
                             <div class="container card-cus-bottom">
                                 <div class="d-flex flex-row row-list">
                                     <div class="p-1 flex-fill bd-highlight left_panel_info">
-                                        <a href="{{ url('/artefact/' . $artefact->id) }}">
+                                        <a href="{{ action('ArtefactController@view', ['id' => $artefact->id]) /*url('/artefact/' . $artefact->id) */}}">
                                             <h5 class="card-title highlight-white">{{$artefact->name}}</h5>
                                         </a>
                                         <h6 class="card-title ">{{$artefact->author}}</h6>
diff --git a/resources/views/inc/sidebar.blade.php b/resources/views/inc/sidebar.blade.php
index 096525d..4bbd9cb 100644
--- a/resources/views/inc/sidebar.blade.php
+++ b/resources/views/inc/sidebar.blade.php
@@ -45,9 +45,9 @@
 
             </li>
             <li class="nav-item down">
-                <a class="menu-item text-headline" href="{{ url('/czech') }}">
-                    {{ __('general.cs') }}
-                </a>
+{{--                <a class="menu-item text-headline" href="{{ url('/czech') }}">--}}
+{{--                    {{ __('general.cs') }}--}}
+{{--                </a>--}}
                 @guest
                 @else
                     <a class="menu-item text-headline" href="{{ route('logout') }}" onclick="
@@ -110,9 +110,9 @@
                 {{ __('general.charts') }}
             </a>
 
-            <a class="menu-item text-headline-desktop" href="{{ url('/czech') }}">
-                {{ __('general.cs') }}
-            </a>
+{{--            <a class="menu-item text-headline-desktop" href="{{ url('/czech') }}">--}}
+{{--                {{ __('general.cs') }}--}}
+{{--            </a>--}}
             @guest
             @else
                 <a class="menu-item text-headline-desktop" href="{{ route('logout') }}" onclick="
diff --git a/routes/web.php b/routes/web.php
index db4e16d..d8127ec 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -30,6 +30,7 @@ Route::resource('/favartefacts', 'FavoriteArtefactsController', array('only' =>
 Route::resource('/charts', 'ChartsController', array('only' => array('index', 'show', 'store')));
 Route::get('/favmetadata', 'FavoriteMetadataController@index');
 Route::get('/favmetadata/unlike/{id}', 'FavoriteMetadataController@unlike');
+Route::get('/artefact/{id}', 'ArtefactController@view');
 
 
 Auth::routes();
