Revize 3ce21235
Přidáno uživatelem Marek Zábran před téměř 5 roky(ů)
app/Http/Controllers/ArtefactController.php | ||
---|---|---|
117 | 117 |
* @param $id int id of the artefact |
118 | 118 |
* @return Factory|View |
119 | 119 |
*/ |
120 |
public function view($id) |
|
120 |
/*public function view($id)
|
|
121 | 121 |
{ |
122 | 122 |
$artefact = Artefact::find($id)->simplePaginate(1); |
123 | 123 |
$artefact = $this->prepData($artefact); |
124 | 124 |
//return view('artefact.view', ['artefact' => $artefact]); |
125 | 125 |
return view('artefact.default', ['artefacts' => $artefact]); |
126 |
} |
|
126 |
}*/
|
|
127 | 127 |
|
128 | 128 |
/** |
129 | 129 |
* Likes artefact given by its id. |
... | ... | |
156 | 156 |
|
157 | 157 |
return back()->withInput(); |
158 | 158 |
} |
159 |
|
|
160 |
/** |
|
161 |
* Returns artefact given by its id. |
|
162 |
* |
|
163 |
* @param $id int id of artefact |
|
164 |
* @return RedirectResponse |
|
165 |
*/ |
|
166 |
public function view($id) |
|
167 |
{ |
|
168 |
//$user = User::find(Auth::id()); |
|
169 |
//$artefact = Artefact::find($id); |
|
170 |
|
|
171 |
$artefacts = Artefact::withCount('users')->orderByDesc('users_count')->get()->take(10); |
|
172 |
|
|
173 |
$currentPage = -1; // You can set this to any page you want to paginate to |
|
174 |
|
|
175 |
for($i=0;$i<10;$i++){ |
|
176 |
if($artefacts[$i]->id==$id) $currentPage = $i+1; |
|
177 |
} |
|
178 |
|
|
179 |
// Make sure that you call the static method currentPageResolver() |
|
180 |
// before querying users |
|
181 |
\Illuminate\Pagination\Paginator::currentPageResolver(function () use ($currentPage) { |
|
182 |
return $currentPage; |
|
183 |
}); |
|
184 |
|
|
185 |
$artefacts = Artefact::withCount('users')->orderByDesc('users_count')->limit(10)->paginate(1); |
|
186 |
|
|
187 |
$artefacts = ArtefactController::prepData($artefacts); |
|
188 |
return view('artefact.default', ['artefacts' => $artefacts]); |
|
189 |
/*foreach($artefacts as $item) |
|
190 |
{ |
|
191 |
$id = $item->id; |
|
192 |
$item['likes'] = Artefact::find($id)->users()->count(); |
|
193 |
$item['favourite'] = is_null(User::find(Auth::id())->likesArtefacts()->find($id)) ? false : true; |
|
194 |
}*/ |
|
195 |
|
|
196 |
|
|
197 |
//return back()->withInput(); |
|
198 |
} |
|
159 | 199 |
} |
resources/views/charts/index.blade.php | ||
---|---|---|
15 | 15 |
<div class="container card-cus-bottom"> |
16 | 16 |
<div class="d-flex flex-row row-list"> |
17 | 17 |
<div class="p-1 flex-fill bd-highlight left_panel_info"> |
18 |
<a href="{{ url('/artefact/' . $artefact->id) }}">
|
|
18 |
<a href="{{ action('ArtefactController@view', ['id' => $artefact->id]) /*url('/artefact/' . $artefact->id) */}}">
|
|
19 | 19 |
<h5 class="card-title highlight-white">{{$artefact->name}}</h5> |
20 | 20 |
</a> |
21 | 21 |
<h6 class="card-title ">{{$artefact->author}}</h6> |
resources/views/inc/sidebar.blade.php | ||
---|---|---|
45 | 45 |
|
46 | 46 |
</li> |
47 | 47 |
<li class="nav-item down"> |
48 |
<a class="menu-item text-headline" href="{{ url('/czech') }}">
|
|
49 |
{{ __('general.cs') }}
|
|
50 |
</a>
|
|
48 |
{{-- <a class="menu-item text-headline" href="{{ url('/czech') }}">--}}
|
|
49 |
{{-- {{ __('general.cs') }}--}}
|
|
50 |
{{-- </a>--}}
|
|
51 | 51 |
@guest |
52 | 52 |
@else |
53 | 53 |
<a class="menu-item text-headline" href="{{ route('logout') }}" onclick=" |
... | ... | |
110 | 110 |
{{ __('general.charts') }} |
111 | 111 |
</a> |
112 | 112 |
|
113 |
<a class="menu-item text-headline-desktop" href="{{ url('/czech') }}">
|
|
114 |
{{ __('general.cs') }}
|
|
115 |
</a>
|
|
113 |
{{-- <a class="menu-item text-headline-desktop" href="{{ url('/czech') }}">--}}
|
|
114 |
{{-- {{ __('general.cs') }}--}}
|
|
115 |
{{-- </a>--}}
|
|
116 | 116 |
@guest |
117 | 117 |
@else |
118 | 118 |
<a class="menu-item text-headline-desktop" href="{{ route('logout') }}" onclick=" |
routes/web.php | ||
---|---|---|
30 | 30 |
Route::resource('/charts', 'ChartsController', array('only' => array('index', 'show', 'store'))); |
31 | 31 |
Route::get('/favmetadata', 'FavoriteMetadataController@index'); |
32 | 32 |
Route::get('/favmetadata/unlike/{id}', 'FavoriteMetadataController@unlike'); |
33 |
Route::get('/artefact/{id}', 'ArtefactController@view'); |
|
33 | 34 |
|
34 | 35 |
|
35 | 36 |
Auth::routes(); |
Také k dispozici: Unified diff
Pokud o paginaci výbrané knihy z charts.