Skip to content

Commit 9288fe0

Browse files
committed
fix testimonial
1 parent 3f3aed0 commit 9288fe0

File tree

7 files changed

+199
-24
lines changed

7 files changed

+199
-24
lines changed

app/Http/Controllers/Backend/Testimonial/TestimonialController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class TestimonialController extends Controller
1515
*/
1616
public function index()
1717
{
18-
$testimonials = Testimonial::latest()->latest()->paginate(paginateCount());
18+
$testimonials = Testimonial::latest()->paginate(paginateCount());
1919
return view('backend.testimonial.view-testimonial', compact('testimonials'));
2020
}
2121

app/Http/Controllers/Frontend/HomeController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function index()
2626
$subCategories = ServiceSubCategory::where('service_category_id', 1)->with('serviceCategory')->latest()->take(6)->latest()->get();
2727
// $products = Product::mappedProducts(['product_category_id' => 1]);
2828
$banners = Banner::latest()->take(6)->latest()->get();
29-
$reviews = Review::latest()->take(6)->latest()->get();
29+
$reviews = Testimonial::latest()->get();
3030
$infos1 = Info::where(['section_id' => 1, 'page_name' => 'homepage'])->latest()->take(4)->latest()->get();
3131
$infos2 = Info::where(['section_id' => 2, 'page_name' => 'homepage'])->latest()->take(4)->latest()->get();
3232
$achievements = Achievement::latest()->take(12)->latest()->get();

app/View/Components/frontend/TestimonialSection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class TestimonialSection extends Component
1111
/**
1212
* Create a new component instance.
1313
*/
14-
public function __construct()
14+
public function __construct(array $reviews = [])
1515
{
1616
}
1717

resources/views/backend/layouts/sidebar.blade.php

+31-10
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,28 @@
176176
</div>
177177
</li>
178178
@endcanany
179+
@canany(['manage reviews'])
180+
<li>
181+
<a href="#sidebarTestimonialSection" data-bs-toggle="collapse">
182+
<i class="mdi mdi-account-check-outline"></i>
183+
<span> Testimonial Section </span>
184+
<span class="menu-arrow"></span>
185+
</a>
186+
<div class="collapse" id="sidebarTestimonialSection">
187+
<ul class="nav-second-level">
188+
<li>
189+
<a href="{{ route('testimonial.create') }}">Create
190+
</a>
191+
</li>
192+
<li>
193+
<a href="{{ route('testimonial.index') }}">
194+
View
195+
</a>
196+
</li>
197+
</ul>
198+
</div>
199+
</li>
200+
@endcanany
179201

180202
</ul>
181203
</div>
@@ -761,18 +783,21 @@
761783
</a>
762784
</li>
763785
<li>
764-
<a href="{{ route('user-appointments.approved') . '?type=consultation' }}">
786+
<a
787+
href="{{ route('user-appointments.approved') . '?type=consultation' }}">
765788
Approved
766789
</a>
767790
</li>
768791
<li>
769-
<a href="{{ route('user-appointments.completed') . '?type=consultation' }}">
792+
<a
793+
href="{{ route('user-appointments.completed') . '?type=consultation' }}">
770794
Completed
771795
</a>
772796
</li>
773797
@if (auth()->user()->role_name == 'expert')
774798
<li>
775-
<a href="{{ route('user-appointments.times') . '?type=consultation' }}">
799+
<a
800+
href="{{ route('user-appointments.times') . '?type=consultation' }}">
776801
Appointment Times
777802
</a>
778803
</li>
@@ -957,7 +982,8 @@
957982
'manage partner request',
958983
'read partner request',
959984
'read role',
960-
'read promo code',
985+
'read
986+
promo code',
961987
'read reviews')
962988
<li class="">
963989
<a href="#management" data-bs-toggle="collapse">
@@ -996,12 +1022,7 @@
9961022
</div>
9971023
</li>
9981024
@endcanany
999-
@canany([
1000-
'create expert',
1001-
'update expert',
1002-
'delete expert',
1003-
'read expert',
1004-
])
1025+
@canany(['create expert', 'update expert', 'delete expert', 'read expert'])
10051026
<li>
10061027
<a href="#expertProfile" data-bs-toggle="collapse">
10071028
<i class="mdi mdi-account-tie"></i>

resources/views/components/frontend/testimonial-section.blade.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,30 @@
33
<div class="scroll-wrapper">
44
<span id="next" class="ti-arrow-circle-left custom-icon"></span>
55
<div class="media-scroller snaps-inline">
6-
@forelse ($reviews as $item)
6+
@forelse ($reviews as $item)
77
<div class="media-elements">
88
<img loading="lazy" src="{{ useImage($item->avatar) }}" alt="img" width="48px" height="48px"
99
class=" rounded-circle shadow-4-strong d-block">
1010
<div>
1111
<div class="mb-2">
1212
<h5 class="mb-0">{{ $item->name }}</h5>
1313
<small>{{ Carbon\Carbon::parse($item->created_at)->diffForHumans() }}</small>
14-
<div class="rating">
15-
@foreach (range(1, 5) as $rating)
16-
@php
17-
$color = $rating > $item->rating ? 'var(--bs-gray-200)' : 'var(--bs-yellow)';
18-
@endphp
19-
<span class="fas fa-star" style="color: {{ $color }};"></span>
20-
@endforeach
21-
</div>
14+
@if ($item->rating)
15+
<div class="rating">
16+
@foreach (range(1, 5) as $rating)
17+
@php
18+
$color = $rating > $item->rating ? 'var(--bs-gray-200)' : 'var(--bs-yellow)';
19+
@endphp
20+
<span class="fas fa-star" style="color: {{ $color }};"></span>
21+
@endforeach
22+
</div>
23+
@endif
2224
</div>
2325
<p class="text-muted mb-0">{{ $item->comment }}
2426
</p>
2527
</div>
2628
</div>
27-
@empty
29+
@empty
2830
<div class="text-center text-light px-5">
2931
No Reviews available
3032
</div>

resources/views/frontend/pages/welcome.blade.php

+152-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,158 @@ class="text-capitalize nav-link {{ $key === 0 ? 'active' : '' }}" tabindex="-1">
6161
<x-frontend.info-card :$info />
6262
@endforeach
6363
</x-frontend.info-section>
64-
<x-frontend.testimonial-section :$reviews />
64+
{{-- @dd($reviews) --}}
65+
<section class="mt-5 py-5" style="background: #474646;">
66+
<h3 class="text-center text-light">Testimonials</h3>
67+
<div class="scroll-wrapper">
68+
<span id="next" class="ti-arrow-circle-left custom-icon"></span>
69+
<div class="media-scroller snaps-inline">
70+
@forelse ($reviews as $item)
71+
<div class="media-elements">
72+
<img loading="lazy" src="{{ useImage($item->avatar) }}" alt="img" width="48px" height="48px"
73+
class=" rounded-circle shadow-4-strong d-block">
74+
<div>
75+
<div class="mb-2">
76+
<h5 class="mb-0">{{ $item->name }}</h5>
77+
<small>{{ Carbon\Carbon::parse($item->created_at)->diffForHumans() }}</small>
78+
@if ($item->rating)
79+
<div class="rating">
80+
@foreach (range(1, 5) as $rating)
81+
@php
82+
$color = $rating > $item->rating ? 'var(--bs-gray-200)' : 'var(--bs-yellow)';
83+
@endphp
84+
<span class="fas fa-star" style="color: {{ $color }};"></span>
85+
@endforeach
86+
</div>
87+
@endif
88+
</div>
89+
<p class="text-muted mb-0">{{ $item->comment }}
90+
</p>
91+
</div>
92+
</div>
93+
@empty
94+
<div class="text-center text-light px-5">
95+
No Reviews available
96+
</div>
97+
@endforelse
98+
</div>
99+
<span id="prev" class="ti-arrow-circle-right custom-icon"></span>
100+
</div>
101+
</section>
102+
103+
@push('customCss')
104+
<style>
105+
.scroll-wrapper {
106+
display: flex;
107+
align-items: center;
108+
justify-content: center;
109+
gap: 10px;
110+
padding: 10px;
111+
}
112+
113+
114+
@media (min-width: 970px) {
115+
.scroll-wrapper {
116+
padding: 1rem 5rem
117+
}
118+
}
119+
120+
@media (min-width: 640px) {
121+
.scroll-wrapper {
122+
gap: 1rem;
123+
padding: 2rem;
124+
}
125+
}
126+
127+
.media-scroller {
128+
display: flex;
129+
overflow-x: auto;
130+
gap: 1rem;
131+
overscroll-behavior-inline: contain;
132+
scroll-behavior: smooth;
133+
}
134+
135+
.media-elements {
136+
display: flex;
137+
align-items: start;
138+
background: white;
139+
border-radius: 10px;
140+
gap: 1rem;
141+
padding: 1rem;
142+
max-width: 45ch;
143+
}
144+
145+
.media-elements .comment {
146+
width: 100px;
147+
display: inline;
148+
margin: 0;
149+
text-align: justify;
150+
}
151+
152+
.media-elements .image {
153+
max-width: 70px;
154+
}
155+
156+
@media (min-width:600px) {
157+
.media-elements .image {
158+
max-width: 120px;
159+
}
160+
161+
.media-elements .comment {
162+
width: 200px
163+
}
164+
}
165+
166+
#next,
167+
#prev {
168+
background: none;
169+
border: none;
170+
padding: 0;
171+
}
172+
173+
.custom-icon {
174+
color: var(--bs-primary);
175+
font-size: 28px;
176+
margin: 0 5px;
177+
cursor: pointer;
178+
}
179+
180+
.media-scroller::-webkit-scrollbar {
181+
appearance: none;
182+
display: none;
183+
}
184+
185+
.snaps-inline {
186+
scroll-snap-type: inline mandatory;
187+
scroll-padding-inline: 5rem;
188+
}
189+
190+
.snaps-inline>* {
191+
scroll-snap-align: start;
192+
}
193+
</style>
194+
@endpush
195+
196+
@push('customJs')
197+
<script>
198+
const container = document.querySelector('.media-scroller');
199+
const next = document.getElementById('next')
200+
const prev = document.getElementById('prev')
201+
const scrollElementWidth = parseInt($('.media-elements').css('width').split('px')[0])
202+
const scrollUnit = scrollElementWidth + 20;
203+
container.addEventListener('wheel', e => {
204+
e.preventDefault();
205+
container.scrollLeft += e.deltaY;
206+
})
207+
208+
next.addEventListener('click', () => {
209+
container.scrollLeft -= scrollUnit;
210+
})
211+
prev.addEventListener('click', () => {
212+
container.scrollLeft += scrollUnit;
213+
})
214+
</script>
215+
@endpush
65216
@endsection
66217

67218
@pushOnce('customJs')

routes/backend.php

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
//Routes for backend CRUD operation
9191

9292
Route::resource('users', UserController::class); // middlewares are in constructor
93+
Route::resource('testimonial', TestimonialController::class)->middleware('can:manage reviews');
9394
Route::get('internal-users', [UserController::class, 'internalUsers'])->name('users.internal');
9495

9596
Route::resource('product', ProductController::class)

0 commit comments

Comments
 (0)