1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Terranet\Administrator\Field; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\View; |
6
|
|
|
use Spatie\MediaLibrary\Models\Media as MediaModel; |
|
|
|
|
7
|
|
|
use Terranet\Administrator\Field\Traits\WorksWithModules; |
8
|
|
|
use Terranet\Administrator\Scaffolding; |
9
|
|
|
|
10
|
|
|
class Media extends Generic |
11
|
|
|
{ |
12
|
|
|
use WorksWithModules; |
13
|
|
|
|
14
|
|
|
protected $conversion = ''; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @param string $conversion |
18
|
|
|
* @return self |
19
|
|
|
*/ |
20
|
|
|
public function convertedTo(string $conversion): self |
21
|
|
|
{ |
22
|
|
|
$this->conversion = $conversion; |
23
|
|
|
|
24
|
|
|
return $this; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @return \Illuminate\Contracts\View\View |
29
|
|
|
*/ |
30
|
|
|
protected function onIndex() |
31
|
|
|
{ |
32
|
|
|
$media = $this->model->getMedia($this->id()); |
33
|
|
|
$module = $this->firstWithModel($this->model) ?: app('scaffold.module'); |
34
|
|
|
|
35
|
|
|
return [ |
|
|
|
|
36
|
|
|
'media' => $media, |
37
|
|
|
'module' => $module, |
38
|
|
|
]; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return \Illuminate\Contracts\View\View |
43
|
|
|
*/ |
44
|
|
|
protected function onView() |
45
|
|
|
{ |
46
|
|
|
$media = $this->model->getMedia($this->id()); |
47
|
|
|
$media = $media->map(function ($item) { |
48
|
|
|
return array_merge($item->toArray(), [ |
49
|
|
|
'url' => $item->getUrl(), |
50
|
|
|
'conversions' => $this->conversions($item), |
51
|
|
|
]); |
52
|
|
|
}); |
53
|
|
|
|
54
|
|
|
return [ |
|
|
|
|
55
|
|
|
'media' => $media, |
56
|
|
|
'conversion' => $this->conversion, |
57
|
|
|
]; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return \Illuminate\Contracts\View\View |
62
|
|
|
*/ |
63
|
|
|
protected function onEdit() |
64
|
|
|
{ |
65
|
|
|
return $this->onView(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param MediaModel $item |
70
|
|
|
* |
71
|
|
|
* @return array |
72
|
|
|
*/ |
73
|
|
|
protected function conversions(MediaModel $item) |
74
|
|
|
{ |
75
|
|
|
return array_build($item->getMediaConversionNames(), function ($key, $conversion) use ($item) { |
76
|
|
|
return [$conversion, $item->getUrl($conversion)]; |
77
|
|
|
}); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths