|
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 |
|
$url = parse_url($this->wrappedObject->social_facebook); |
|
25
|
|
|
|
|
26
|
3 |
|
if(!$this->wrappedObject->social_facebook || !array_key_exists('path', $url)){ |
|
27
|
1 |
|
return "<img class=\"img-thumbnail\" src=\"//placehold.it/100x100\" height=\"100\" width=\"100\" alt=\"{$this->wrappedObject->name}\"/>"; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
2 |
|
$userId = trim($url['path'], '/'); |
|
31
|
|
|
|
|
32
|
2 |
|
if ($url['path'] == '/profile.php') { |
|
33
|
1 |
|
parse_str($url['query'], $parts); |
|
34
|
1 |
|
$userId = $parts['id']; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
2 |
|
$url = "http://graph.facebook.com/{$userId}/picture?type=$type"; |
|
38
|
|
|
|
|
39
|
2 |
|
return "<img class=\"img-thumbnail media-object\" src=\"$url\" height=\"100\" width=\"100\" alt=\"{$this->wrappedObject->name}\"/>"; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* get Google Static Map img. |
|
44
|
|
|
* |
|
45
|
|
|
* @param int $zoom Zoom Level |
|
46
|
|
|
* |
|
47
|
|
|
* @return string HTML code to render img with map |
|
48
|
|
|
*/ |
|
49
|
1 |
|
public function staticMap($zoom = 15) |
|
50
|
|
|
{ |
|
51
|
|
|
$data = [ |
|
52
|
1 |
|
'center' => $this->wrappedObject->postal_address, |
|
53
|
1 |
|
'zoom' => intval($zoom), |
|
54
|
1 |
|
'scale' => '2', |
|
55
|
1 |
|
'size' => '180x100', |
|
56
|
1 |
|
'maptype' => 'roadmap', |
|
57
|
1 |
|
'format' => 'gif', |
|
58
|
1 |
|
'visual_refresh' => 'true', ]; |
|
59
|
|
|
|
|
60
|
1 |
|
$src = 'http://maps.googleapis.com/maps/api/staticmap?'.http_build_query($data, '', '&'); |
|
61
|
|
|
|
|
62
|
1 |
|
return "<img class=\"img-responsive img-thumbnail center-block\" width=\"180\" height=\"100\" src=\"$src\"/>"; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* get Industry Icon. |
|
67
|
|
|
* |
|
68
|
|
|
* @return string HTML code to render img with icon |
|
69
|
|
|
*/ |
|
70
|
1 |
|
public function industryIcon() |
|
71
|
|
|
{ |
|
72
|
1 |
|
$src = asset('/img/industries/'.$this->wrappedObject->category->slug.'.png'); |
|
73
|
|
|
|
|
74
|
1 |
|
return "<img class=\"img-responsive center-block\" src=\"{$src}\"/>"; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|