| Total Complexity | 6 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class Media extends Field |
||
| 9 | { |
||
| 10 | /** @var string */ |
||
| 11 | protected $collection = 'default'; |
||
| 12 | |||
| 13 | /** @var string */ |
||
| 14 | protected $conversion = ''; |
||
| 15 | |||
| 16 | /** @var int */ |
||
| 17 | protected $perPage = 10; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param string $collection |
||
| 21 | * @return $this |
||
| 22 | */ |
||
| 23 | public function fromCollection(string $collection) |
||
| 24 | { |
||
| 25 | $this->collection = $collection; |
||
| 26 | |||
| 27 | return $this; |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param string $conversion |
||
| 32 | * |
||
| 33 | * @return self |
||
| 34 | */ |
||
| 35 | public function convertedTo(string $conversion): self |
||
| 36 | { |
||
| 37 | $this->conversion = $conversion; |
||
| 38 | |||
| 39 | return $this; |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @return array |
||
| 44 | */ |
||
| 45 | protected function onIndex(): array |
||
| 46 | { |
||
| 47 | return [ |
||
| 48 | 'count' => MediaLibraryProvider::forModel($this->model)->count($this->collection), |
||
| 49 | 'module' => Architect::resourceByEntity($this->model) ?: app('scaffold.module'), |
||
|
|
|||
| 50 | ]; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @return array |
||
| 55 | */ |
||
| 56 | protected function onView(): array |
||
| 61 | ]; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return array |
||
| 66 | */ |
||
| 67 | protected function onEdit(): array |
||
| 70 | } |
||
| 71 | } |
||
| 72 |