1 | <?php |
||
12 | class MediaRepository |
||
13 | { |
||
14 | /** @var \Spatie\MediaLibrary\Models\Media */ |
||
15 | protected $model; |
||
16 | |||
17 | /** @param \Spatie\MediaLibrary\Models\Media $model */ |
||
18 | public function __construct(Media $model) |
||
22 | |||
23 | /** |
||
24 | * Get all media in the collection. |
||
25 | * |
||
26 | * @param \Spatie\MediaLibrary\HasMedia\HasMedia $model |
||
27 | * @param string $collectionName |
||
28 | * @param array|callable $filter |
||
29 | * |
||
30 | * @return \Illuminate\Support\Collection |
||
31 | */ |
||
32 | public function getCollection(HasMedia $model, string $collectionName, $filter = []): Collection |
||
36 | |||
37 | /** |
||
38 | * Apply given filters on media. |
||
39 | * |
||
40 | * @param \Illuminate\Support\Collection $media |
||
41 | * @param array|callable $filter |
||
42 | * |
||
43 | * @return \Illuminate\Support\Collection |
||
44 | */ |
||
45 | protected function applyFilterToMediaCollection(Collection $media, $filter): Collection |
||
53 | |||
54 | public function all(): DbCollection |
||
58 | |||
59 | public function getByModelType(string $modelType): DbCollection |
||
63 | |||
64 | public function getByIds(array $ids): DbCollection |
||
68 | |||
69 | public function getByModelTypeAndCollectionName(string $modelType, string $collectionName): DbCollection |
||
76 | |||
77 | public function getByCollectionName(string $collectionName): DbCollection |
||
83 | |||
84 | /** |
||
85 | * Convert the given array to a filter function. |
||
86 | * |
||
87 | * @param $filters |
||
88 | * |
||
89 | * @return \Closure |
||
90 | */ |
||
91 | protected function getDefaultFilterFunction(array $filters): Closure |
||
107 | } |
||
108 |