forked from ushahidi/platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMediaRepository.php
More file actions
71 lines (58 loc) · 1.68 KB
/
Copy pathMediaRepository.php
File metadata and controls
71 lines (58 loc) · 1.68 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
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* Ushahidi Media Repository
*
* @author Ushahidi Team <team@ushahidi.com>
* @package Ushahidi\Application
* @copyright 2014 Ushahidi
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3)
*/
namespace Ushahidi\App\Repository;
use Ohanzee\Database;
use Ushahidi\Core\Data;
use Ushahidi\Core\SearchData;
use Ushahidi\Core\Entity\Media;
use Ushahidi\Core\Entity\MediaRepository as MediaRepositoryContract;
use Ushahidi\Core\Tool\Uploader;
use Ushahidi\Core\Tool\UploadData;
class MediaRepository extends OhanzeeRepository implements
MediaRepositoryContract
{
private $upload;
private $created_id;
private $created_ts;
private $deleted_media;
public function __construct(\Ushahidi\App\Multisite\OhanzeeResolver $resolver, Uploader $upload)
{
parent::__construct($resolver);
$this->upload = $upload;
}
// OhanzeeRepository
protected function getTable()
{
return 'media';
}
// OhanzeeRepository
public function getEntity(array $data = null)
{
return new Media($data);
}
// SearchRepository
public function getSearchFields()
{
return ['user', 'orphans'];
}
// OhanzeeRepository
protected function setSearchConditions(SearchData $search)
{
if ($search->user) {
$this->search_query->where('user_id', '=', $search->user);
}
if ($search->orphans) {
$this->search_query
->join('posts_media', 'left')
->on('posts_media.media_id', '=', 'media.id')
->where('posts_media.post_id', 'is', null);
}
}
}