File: D:/HostingSpaces/Neopoints/momsecurity.be/app/Testimonials/TestimonialService.php
<?php
namespace App\Testimonials;
use App\Base\Service;
use App\Posts\Models\Post;
use App\Testimonials\Models\Testimonial;
use Carbon\Carbon;
final class TestimonialService extends Service
{
/**
* @return \Illuminate\Database\Eloquent\Builder
*/
private function baseTestimonialQuery()
{
return Testimonial::with('translation', 'images')
->where('active', 1)
->orderBy('lft')
->whereHas('translation');
}
public function getAllTestimonials($pagination = false, $itemsPerPage = 9)
{
$testimonialsQuery = $this->baseTestimonialQuery();
if($pagination) $testimonials = $testimonialsQuery->paginate($itemsPerPage);
else $testimonials = $testimonialsQuery->get();
return $testimonials;
}
public function getNextTestimonials(Testimonial $testimonial)
{
return $this->baseTestimonialQuery()
->where('lft', '>', $testimonial->lft)
->take(3)
->get();
}
}