1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DavideCasiraghi\LaravelJumbotronImages; |
4
|
|
|
|
5
|
|
|
use DavideCasiraghi\LaravelJumbotronImages\Models\JumbotronImage; |
6
|
|
|
|
7
|
|
|
class LaravelJumbotronImages |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Return a Jumbotron image. |
11
|
|
|
* |
12
|
|
|
* @return \DavideCasiraghi\LaravelJumbotronImages\Models\JumbotronImage |
13
|
|
|
*/ |
14
|
1 |
|
public function getJumbotronImage($jumbotronImageId) |
15
|
|
|
{ |
16
|
1 |
|
$jumbotronImage = JumbotronImage::find($jumbotronImageId); |
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
|
1 |
|
public function showJumbotronImage($jumbotronImageId) |
32
|
|
|
{ |
33
|
1 |
|
$jumbotronImage = JumbotronImage::find($jumbotronImageId); |
34
|
1 |
|
$jumbotronImage->parameters = $this->getParametersArray($jumbotronImage); |
|
|
|
|
35
|
|
|
|
36
|
1 |
|
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
|
3 |
|
public static function getParametersArray($jumbotronImage) |
47
|
|
|
{ |
48
|
|
|
$ret = [ |
49
|
3 |
|
'cover_opacity' => 'opacity: '.$jumbotronImage->cover_opacity.';', |
50
|
3 |
|
'background_color' => 'background: #'.$jumbotronImage->background_color.';', |
51
|
3 |
|
'image' => 'background-image:url(/storage/images/jumbotron_images/'.$jumbotronImage->image_file_name.');', |
52
|
3 |
|
'text_horizontal_alignment' => 'text-align: '.$jumbotronImage->text_horizontal_alignment.';', |
53
|
|
|
]; |
54
|
3 |
|
$ret['white_moon'] = ($jumbotronImage->white_moon == 1) ? " moon-curve " : ""; |
55
|
3 |
|
$ret['scroll_down_arrow'] = ($jumbotronImage->scroll_down_arrow == 1) ? "<div class='scroll-arrow white'><span>SCROLL DOWN</span><img src='/vendor/laravel-jumbotron-images/assets/images/angle-down-regular.svg'></div>" : ""; |
56
|
|
|
|
57
|
|
|
/* Parallax - The element is defined with stellar plugin like: <section class="parallax" data-stellar-background-ratio="0.5" ><span>Summer</span></section>*/ |
58
|
3 |
|
$ret['parallax'] = ($jumbotronImage->parallax == 1) ? " parallax" : ""; |
59
|
3 |
|
$ret['parallax_ratio'] = ($jumbotronImage->parallax == 1) ? "data-stellar-background-ratio='0.5'" : ""; |
60
|
|
|
|
61
|
|
|
/* Text Width */ |
62
|
3 |
|
if ($jumbotronImage->text_width != 100) { |
63
|
3 |
|
switch ($jumbotronImage->text_horizontal_alignment) { |
64
|
3 |
|
case 'left': // Left |
65
|
|
|
$ret['text_width'] = 'width: '.$jumbotronImage->text_width.'%;'; |
66
|
|
|
break; |
67
|
3 |
|
case 'center': // Center |
68
|
1 |
|
$ret['text_width'] = 'width: '.$jumbotronImage->text_width.'%; margin: auto;'; |
69
|
1 |
|
break; |
70
|
2 |
|
case 'right': // Right |
71
|
|
|
$ret['text_width'] = 'width: '.$jumbotronImage->text_width.'%; float: right;'; |
72
|
|
|
break; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
3 |
|
return $ret; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.