forked from ushahidi/platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSiteRepository.php
More file actions
59 lines (48 loc) · 1.57 KB
/
Copy pathSiteRepository.php
File metadata and controls
59 lines (48 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* Multsite Site Repo
*
* @author Ushahidi Team <team@ushahidi.com>
* @package Ushahidi\Platform
* @copyright 2014 Ushahidi
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3)
*/
namespace Ushahidi\App\Multisite;
use Illuminate\Database\ConnectionResolverInterface;
use Illuminate\Support\Facades\DB;
class SiteRepository
{
protected $connection;
public function __construct()
{
$this->connection = DB::connection('multisite');
}
public function getByDomain($subdomain, $domain)
{
$result = $this->connection->table('deployments')
->select('deployments.*', 'tiers.key as tier')
// Note this is an inner join, so a deployment without a tier won't be found
->join('tiers', 'tiers.id', '=', 'deployments.tier_id')
->where(compact('subdomain', 'domain'))
->first()
;
if (!$result) {
return false;
}
return new Site(collect($result)->toArray());
}
public function getById($id)
{
$result = $this->connection->table('deployments')
->select('deployments.*', 'tiers.key as tier')
// Note this is an inner join, so a deployment without a tier won't be found
->join('tiers', 'tiers.id', '=', 'deployments.tier_id')
->where('deployments.id', '=', $id)
->first()
;
if (!$result) {
return false;
}
return new Site(collect($result)->toArray());
}
}