-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathAssetQueryBuilder.php
More file actions
36 lines (29 loc) · 1.02 KB
/
AssetQueryBuilder.php
File metadata and controls
36 lines (29 loc) · 1.02 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
<?php
namespace Statamic\Eloquent\Assets;
use Statamic\Assets\AssetCollection;
use Statamic\Contracts\Assets\QueryBuilder;
use Statamic\Query\EloquentQueryBuilder;
class AssetQueryBuilder extends EloquentQueryBuilder implements QueryBuilder
{
const COLUMNS = [
'id', 'container', 'folder', 'basename', 'filename', 'extension', 'path', 'size', 'width', 'height', 'duration', 'mime_type', 'last_modified', 'created_at', 'updated_at',
];
protected function column($column)
{
if (! in_array($column, self::COLUMNS)) {
$column = 'meta->'.$column;
}
return $column;
}
protected function transform($items, $columns = [])
{
return AssetCollection::make($items)->map(function ($model) use ($columns) {
return app('statamic.eloquent.assets.asset')::fromModel($model)
->selectedQueryColumns($this->selectedQueryColumns ?? $columns);
});
}
public function with($relations, $callback = null)
{
return $this;
}
}