|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace DavideCasiraghi\LaravelJumbotronImages; |
|
4
|
|
|
|
|
5
|
|
|
use DavideCasiraghi\LaravelJumbotronImages\Models\JumbotronImage; |
|
6
|
|
|
|
|
7
|
|
|
class LaravelJumbotronImages |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Return a random quote. |
|
11
|
|
|
* |
|
12
|
|
|
* @return \DavideCasiraghi\LaravelJumbotronImages\Models\JumbotronImage |
|
13
|
|
|
*/ |
|
14
|
1 |
|
public function getJumbotronImage($id) |
|
15
|
|
|
{ |
|
16
|
1 |
|
$jumbotronImage = JumbotronImage::find($id); |
|
17
|
1 |
|
$jumbotronImage->parameters = $this->getParametersArray($jumbotronImage); |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
1 |
|
$ret = $jumbotronImage; |
|
20
|
|
|
|
|
21
|
1 |
|
return $ret; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/*****************************/ |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Show a Jumbotron Image. |
|
28
|
|
|
* |
|
29
|
|
|
* @return \DavideCasiraghi\LaravelJumbotronImages\Models\JumbotronImage |
|
30
|
|
|
*/ |
|
31
|
|
|
public function showJumbotronImage($jumbotronImageId) |
|
32
|
|
|
{ |
|
33
|
|
|
$jumbotronImage = JumbotronImage::find($jumbotronImageId); |
|
34
|
|
|
$jumbotronImage->parameters = $this->getParametersArray($jumbotronImage); |
|
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
return view('laravel-jumbotron-images::jumbotronImages.show', compact('jumbotronImage')); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/***************************************************************************/ |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Attach to the jumbotron image object an array with the parameters for the show-jumbotron-image view. |
|
43
|
|
|
* |
|
44
|
|
|
* @return array |
|
45
|
|
|
*/ |
|
46
|
1 |
|
public static function getParametersArray($jumbotronImage) |
|
47
|
|
|
{ |
|
48
|
|
|
$ret = [ |
|
49
|
1 |
|
'cover_opacity' => 'opacity: '.$jumbotronImage->cover_opacity.';', |
|
50
|
1 |
|
'background_color' => 'background: #'.$jumbotronImage->background_color.';', |
|
51
|
1 |
|
'image' => 'background-image:url(/storage/images/jumbotron_images/'.$jumbotronImage->image_file_name.');', |
|
52
|
|
|
]; |
|
53
|
|
|
|
|
54
|
|
|
/* Parallax - The element is defined with stellar plugin like: <section class="parallax" data-stellar-background-ratio="0.5" ><span>Summer</span></section>*/ |
|
55
|
1 |
|
if ($jumbotronImage->parallax == 1) { |
|
56
|
|
|
$ret['parallax'] = ' parallax'; |
|
57
|
|
|
$ret['parallax_ratio'] = "data-stellar-background-ratio='0.5'"; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
1 |
|
if ($jumbotronImage->white_moon == 1) { |
|
61
|
|
|
$ret['white_moon'] = ' moon-curve '; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/* Scroll down arrow */ |
|
65
|
1 |
|
if ($jumbotronImage->scroll_down_arrow == 1) { |
|
66
|
|
|
$ret['scroll_down_arrow'] = "<div class='scroll-arrow white'><span>SCROLL DOWN</span><img src='/vendor/laravel-jumbotron-images/assets/images/angle-down-regular.svg'></div>"; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
1 |
|
switch ($jumbotronImage->text_horizontal_alignment) { |
|
70
|
1 |
|
case 0: |
|
71
|
1 |
|
$ret['text_horizontal_alignment'] = "text-align: left;"; |
|
72
|
1 |
|
break; |
|
73
|
|
|
case 1: |
|
74
|
|
|
$ret['text_horizontal_alignment'] = "text-align: center;"; |
|
75
|
|
|
break; |
|
76
|
|
|
case 2: |
|
77
|
|
|
$ret['text_horizontal_alignment'] = "text-align: right;"; |
|
78
|
|
|
break; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
1 |
|
if ($jumbotronImage->text_width != 100) { |
|
82
|
1 |
|
switch ($jumbotronImage->text_horizontal_alignment) { |
|
83
|
1 |
|
case 0: // Left |
|
84
|
1 |
|
$ret['text_width'] = 'width: '.$jumbotronImage->text_width.'%;'; |
|
85
|
1 |
|
break; |
|
86
|
|
|
case 1: // Center |
|
87
|
|
|
$ret['text_width'] = 'width: '.$jumbotronImage->text_width.'%; margin: auto;'; |
|
88
|
|
|
break; |
|
89
|
|
|
case 2: // Right |
|
90
|
|
|
$ret['text_width'] = 'width: '.$jumbotronImage->text_width.'%; float: right;'; |
|
91
|
|
|
break; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
|
|
96
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
|
|
99
|
1 |
|
return $ret; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.