1 | <?php |
||
9 | class MediaRepository |
||
10 | { |
||
11 | /** |
||
12 | * @var \Spatie\MediaLibrary\Media |
||
13 | */ |
||
14 | protected $model; |
||
15 | |||
16 | /** |
||
17 | * @param \Spatie\MediaLibrary\Media $model |
||
18 | */ |
||
19 | public function __construct(Media $model) |
||
23 | |||
24 | /** |
||
25 | * Get all media in the collection. |
||
26 | * |
||
27 | * @param HasMedia $model |
||
28 | * @param string $collectionName |
||
29 | * @param array|callable $filter |
||
30 | * |
||
31 | * @return Collection |
||
32 | */ |
||
33 | public function getCollection(HasMedia $model, string $collectionName, $filter = []) : Collection |
||
41 | |||
42 | /** |
||
43 | * Apply given filters on media. |
||
44 | * |
||
45 | * @param \Illuminate\Support\Collection $media |
||
46 | * @param array|callable $filter |
||
47 | * |
||
48 | * @return Collection |
||
49 | */ |
||
50 | protected function applyFilterToMediaCollection(Collection $media, $filter) : Collection |
||
58 | |||
59 | /** |
||
60 | * Get all media. |
||
61 | */ |
||
62 | public function all() : DbCollection |
||
66 | |||
67 | /* |
||
68 | * Get all media for the given type. |
||
69 | */ |
||
70 | public function getByModelType(string $modelType) : DbCollection |
||
74 | |||
75 | /* |
||
76 | * Get media by ids. |
||
77 | */ |
||
78 | public function getByIds(array $ids) : DbCollection |
||
82 | |||
83 | /* |
||
84 | * Get all media for the given type and collection name. |
||
85 | */ |
||
86 | public function getByModelTypeAndCollectionName(string $modelType, string $collectionName) : DbCollection |
||
93 | |||
94 | /* |
||
95 | * Get all media for the given type and collection name. |
||
96 | */ |
||
97 | public function getByCollectionName(string $collectionName) : DbCollection |
||
103 | |||
104 | /** |
||
105 | * Convert the given array to a filter function. |
||
106 | * |
||
107 | * @param $filters |
||
108 | * |
||
109 | * @return \Closure |
||
110 | */ |
||
111 | protected function getDefaultFilterFunction(array $filters) |
||
128 | } |
||
129 |