1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Timegridio\Concierge\Presenters; |
4
|
|
|
|
5
|
|
|
use McCool\LaravelAutoPresenter\BasePresenter; |
6
|
|
|
use Timegridio\Concierge\Models\Business; |
7
|
|
|
|
8
|
|
|
class BusinessPresenter extends BasePresenter |
9
|
|
|
{ |
10
|
6 |
|
public function __construct(Business $resource) |
11
|
|
|
{ |
12
|
6 |
|
$this->wrappedObject = $resource; |
13
|
6 |
|
} |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* get Facebook Profile Public Picture. |
17
|
|
|
* |
18
|
|
|
* @param string $type Type of picture to print |
19
|
|
|
* |
20
|
|
|
* @return string HTML code to render img with facebook picture |
21
|
|
|
*/ |
22
|
3 |
|
public function facebookImg($type = 'square') |
23
|
|
|
{ |
24
|
3 |
|
if (!$this->wrappedObject->social_facebook) { |
25
|
1 |
|
return '<img class="img-thumbnail" src="//placehold.it/100x100"/>'; |
26
|
|
|
} |
27
|
2 |
|
$url = parse_url($this->wrappedObject->social_facebook); |
28
|
|
|
|
29
|
2 |
|
$userId = trim($url['path'], '/'); |
30
|
|
|
|
31
|
2 |
|
if ($url['path'] == '/profile.php') { |
32
|
1 |
|
parse_str($url['query'], $parts); |
33
|
1 |
|
$userId = $parts['id']; |
34
|
1 |
|
} |
35
|
|
|
|
36
|
2 |
|
$url = "http://graph.facebook.com/{$userId}/picture?type=$type"; |
37
|
|
|
|
38
|
2 |
|
return "<img class=\"img-thumbnail media-object\" src='$url' />"; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* get Google Static Map img. |
43
|
|
|
* |
44
|
|
|
* @param int $zoom Zoom Level |
45
|
|
|
* |
46
|
|
|
* @return string HTML code to render img with map |
47
|
|
|
*/ |
48
|
1 |
|
public function staticMap($zoom = 15) |
49
|
|
|
{ |
50
|
|
|
$data = [ |
51
|
1 |
|
'center' => $this->wrappedObject->postal_address, |
52
|
1 |
|
'zoom' => intval($zoom), |
53
|
1 |
|
'scale' => '2', |
54
|
1 |
|
'size' => '180x100', |
55
|
1 |
|
'maptype' => 'roadmap', |
56
|
1 |
|
'format' => 'gif', |
57
|
1 |
|
'visual_refresh' => 'true', ]; |
58
|
|
|
|
59
|
1 |
|
$src = 'http://maps.googleapis.com/maps/api/staticmap?'.http_build_query($data, '', '&'); |
60
|
|
|
|
61
|
1 |
|
return "<img class=\"img-responsive img-thumbnail center-block\" src=\"$src\"/>"; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* get Industry Icon. |
66
|
|
|
* |
67
|
|
|
* @return string HTML code to render img with icon |
68
|
|
|
*/ |
69
|
1 |
|
public function industryIcon() |
70
|
|
|
{ |
71
|
1 |
|
if (!isset($this->wrappedObject)) { |
72
|
|
|
return ''; |
73
|
|
|
} |
74
|
|
|
|
75
|
1 |
|
$src = asset('/img/industries/'.$this->wrappedObject->category->slug.'.png'); |
76
|
|
|
|
77
|
1 |
|
return "<img class=\"img-responsive center-block\" src=\"{$src}\"/>"; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|