Revize d7feebff
Přidáno uživatelem Marek Zábran před téměř 5 roky(ů)
app/Http/Controllers/ChartsController.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
namespace App\Http\Controllers; |
|
4 |
|
|
5 |
use Illuminate\Contracts\Foundation\Application; |
|
6 |
use Illuminate\Contracts\View\Factory; |
|
7 |
use Illuminate\Support\Facades\Auth; |
|
8 |
use App\Artefact; |
|
9 |
use App\Http\Controllers\Image; |
|
10 |
use Illuminate\View\View; |
|
11 |
|
|
12 |
class ChartsController extends Controller |
|
13 |
{ |
|
14 |
public function __construct() |
|
15 |
{ |
|
16 |
$this->middleware('auth'); |
|
17 |
} |
|
18 |
|
|
19 |
/** |
|
20 |
* Display a listing of the resource. |
|
21 |
* |
|
22 |
* @return Application|Factory|View |
|
23 |
*/ |
|
24 |
public function index() |
|
25 |
{ |
|
26 |
if(Auth::check()) |
|
27 |
{ |
|
28 |
$artefacts = Artefact::all(); |
|
29 |
foreach($artefacts as $item) |
|
30 |
{ |
|
31 |
$item['likes'] = Artefact::find($item->id)->users()->count(); |
|
32 |
} |
|
33 |
$artefacts=$artefacts->sortByDesc('likes'); |
|
34 |
|
|
35 |
$data = array( |
|
36 |
'title' => 'Charts', |
|
37 |
'artefacts' => $artefacts |
|
38 |
); |
|
39 |
return view('favartefacts.index') -> with($data); |
|
40 |
} |
|
41 |
else |
|
42 |
{ |
|
43 |
$data = array( |
|
44 |
'title' => 'Welcome to the MERLOT page', |
|
45 |
); |
|
46 |
//return view('index', compact('title')); |
|
47 |
return view('pages.index') -> with($data); |
|
48 |
} |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* Display the specified resource. |
|
53 |
* |
|
54 |
* @return Application|Factory|View |
|
55 |
*/ |
|
56 |
public function show() |
|
57 |
{ |
|
58 |
$artefacts = Artefact::all(); |
|
59 |
foreach($artefacts as $item) |
|
60 |
{ |
|
61 |
$item['likes'] = Artefact::find($item->id)->users()->count(); |
|
62 |
} |
|
63 |
$artefacts=$artefacts->sortByDesc('likes'); |
|
64 |
|
|
65 |
$data = array( |
|
66 |
'title' => 'Charts', |
|
67 |
'artefacts' => $artefacts |
|
68 |
); |
|
69 |
return view('charts.index') -> with($data); |
|
70 |
} |
|
71 |
|
|
72 |
} |
resources/sass/_custom.scss | ||
---|---|---|
776 | 776 |
border: 0; |
777 | 777 |
&:active, &.active, &:focus{ |
778 | 778 |
color: $theme-color-one; |
779 |
background-color: $theme-color-five; |
|
779 |
//background-color: $theme-color-five;
|
|
780 | 780 |
border: none; |
781 | 781 |
outline: none; |
782 | 782 |
box-shadow: none; |
resources/views/charts/index.blade.php | ||
---|---|---|
1 |
@extends('layouts.app') |
|
2 |
|
|
3 |
@section('title', 'Charts') |
|
4 |
|
|
5 |
@section('content') |
|
6 |
<div class="container"> |
|
7 |
{{--<p>The id of the user is {{$user->id}}</p>--}} |
|
8 |
@if(isset($artefacts)) |
|
9 |
@if(count($artefacts) >= 1) |
|
10 |
@foreach($artefacts as $artefact) |
|
11 |
<div class="artefacts-area mb-5"> |
|
12 |
<div class="card"> |
|
13 |
{{--<svg class="bd-placeholder-img card-img-top" width="100%" height="180" src="{{asset('images/artefacts/book_cover_01.jpg')}}" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Image cap"><title>{{$artefact[0]->name}}</title><rect width="100%" height="100%" fill="#868e96"></rect><text x="45%" y="50%" fill="#dee2e6" dy=".3em"></text></svg>--}} |
|
14 |
<a href="{{ url('/artefact/' . $artefact->id) }}"> |
|
15 |
<img class="card-img-top" src="{{asset('images/artefacts/book_cover_01.jpg')}}" width="100%" height=auto> |
|
16 |
</a> |
|
17 |
<div class="container card-cus-bottom"> |
|
18 |
<div class="flex-row row-list"> |
|
19 |
<div class="col-xs-2 float-left left_panel_info"> |
|
20 |
<h5 class="card-title ">{{$artefact->name}}</h5> |
|
21 |
<h6 class="card-title">{{$artefact->author}}</h6> |
|
22 |
</div> |
|
23 |
<div class="col-xs-2 float-right right_panel_info"> |
|
24 |
<div class="float-left"> |
|
25 |
<button id="info_butt_{{$artefact->id}}" type="button" class="btn btn-primary button-image inter_info"></button> |
|
26 |
</div> |
|
27 |
<div class="float-right text-center"> |
|
28 |
<button id="like_butt_{{$artefact->id}}" onclick="myFunction({{$artefact->id}}, 1)" type="button" class="btn btn-primary button-image inter_like"></button> |
|
29 |
<button id="like_butt2_{{$artefact->id}}" onclick="myFunction({{$artefact->id}}, 0)" type="button" class="btn btn-primary button-image inter_like_filled"></button> |
|
30 |
<span class="likes_text"> |
|
31 |
<h6>{{$artefact->likes}}</h6> |
|
32 |
</span> |
|
33 |
</div> |
|
34 |
</div> |
|
35 |
</div> |
|
36 |
</div> |
|
37 |
</div> |
|
38 |
</div> |
|
39 |
@endforeach |
|
40 |
@else |
|
41 |
<ul class="list-group"> |
|
42 |
<li class="list-group-item"> |
|
43 |
<h3>No favorites were added!</h3> |
|
44 |
</li> |
|
45 |
</ul> |
|
46 |
@endif |
|
47 |
@else |
|
48 |
<ul class="list-group"> |
|
49 |
<li class="list-group-item"> |
|
50 |
<h3>Not found the USER in the database with number id {{$user->id}}!</h3> |
|
51 |
</li> |
|
52 |
</ul> |
|
53 |
@endif |
|
54 |
</div> |
|
55 |
<script> |
|
56 |
function myFunction(id, type) |
|
57 |
{ |
|
58 |
if(type === 1) |
|
59 |
{ |
|
60 |
$('#like_butt_' + id).css('display', "none"); |
|
61 |
$('#like_butt2_' + id).css('display', "inline"); |
|
62 |
} |
|
63 |
else |
|
64 |
{ |
|
65 |
$('#like_butt_' + id).css('display', "inline"); |
|
66 |
$('#like_butt2_' + id).css('display', "none"); |
|
67 |
} |
|
68 |
} |
|
69 |
</script> |
|
70 |
@endsection |
routes/web.php | ||
---|---|---|
25 | 25 |
Route::resource('/detail', 'DetailsController', array('only' => array('index', 'show'))); |
26 | 26 |
Route::resource('/categories', 'CategoriesController', array('only' => array('index'))); |
27 | 27 |
Route::resource('/favartefacts', 'FavoriteArtefactsController', array('only' => array('index', 'show', 'store'))); |
28 |
Route::resource('/charts', 'ChartsController', array('only' => array('index', 'show', 'store'))); |
|
28 | 29 |
Route::get('/favmetadata', 'FavoriteMetadataController@index'); |
29 | 30 |
Route::get('/favmetadata/unlike/{id}', 'FavoriteMetadataController@unlike'); |
30 | 31 |
|
Také k dispozici: Unified diff
Issue #7959 @0.5h
První rychlá verze Charts. Styl by asi měl odpovídat FavArtefacts, takže je kopíruji.
[/] Oprava tlačítek v horní lište, už nemají pozadí.