|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Services\PostService; |
|
6
|
|
|
use App\Services\StaticPageService; |
|
7
|
|
|
use App\Services\TestimonialService; |
|
8
|
|
|
|
|
9
|
|
|
class HomeController extends Controller |
|
10
|
|
|
{ |
|
11
|
|
|
private PostService $postService; |
|
12
|
|
|
private StaticPageService $staticPageService; |
|
13
|
|
|
private TestimonialService $testimonialService; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Create a new controller instance. |
|
17
|
|
|
* |
|
18
|
|
|
* @param PostService $postService |
|
19
|
|
|
* @param StaticPageService $staticPageService |
|
20
|
|
|
* @param TestimonialService $testimonialService |
|
21
|
|
|
*/ |
|
22
|
|
|
public function __construct( |
|
23
|
|
|
PostService $postService, |
|
24
|
|
|
StaticPageService $staticPageService, |
|
25
|
|
|
TestimonialService $testimonialService |
|
26
|
|
|
) { |
|
27
|
|
|
$this->postService = $postService; |
|
28
|
|
|
$this->staticPageService = $staticPageService; |
|
29
|
|
|
$this->testimonialService = $testimonialService; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Show the application dashboard. |
|
34
|
|
|
* |
|
35
|
|
|
* @return \Illuminate\Contracts\Support\Renderable |
|
36
|
|
|
*/ |
|
37
|
|
|
public function index() |
|
38
|
|
|
{ |
|
39
|
|
|
$posts = $this->postService->getPosts(); |
|
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
$videoIntro = $this->staticPageService->getStaticImageHtml('1'); |
|
42
|
|
|
|
|
43
|
|
|
$lastPosts = $this->postService->getPosts(3, ['status' => 'published']); |
|
44
|
|
|
|
|
45
|
|
|
$testimonials = $this->testimonialService->getTestimonials(null, ['status' => 'published']); |
|
46
|
|
|
$random = $testimonials->random(3); |
|
47
|
|
|
|
|
48
|
|
|
return view('home', [ |
|
49
|
|
|
'lastPosts' => $lastPosts, |
|
50
|
|
|
'videoIntro' => $videoIntro, |
|
51
|
|
|
'testimonials' => $random |
|
52
|
|
|
]); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|