forked from dystcz/nova-medialibrary-field
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MediaFields.php
44 lines (33 loc) · 1.32 KB
/
MediaFields.php
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
37
38
39
40
41
42
43
44
<?php
declare(strict_types=1);
namespace Aqjw\MedialibraryField\Fields\Support;
use Aqjw\MedialibraryField\Fields\GeneratedConversions;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Textarea;
class MediaFields
{
public static function make(): callable
{
return function (Request $request) {
return [
ID::make(),
Text::make(__('Media Filename'), 'file_name')
->rules('required', 'min:2'),
Textarea::make(__('Media Description'), 'custom_properties->description')->alwaysShow(),
Text::make(__('Media Disk'))->exceptOnForms(),
Text::make(__('Media Download Url'), function () {
return $this->resource->exists ? $this->resource->getFullUrl() : null;
}),
Text::make(__('Media Size'))->displayUsing(function () {
return $this->resource->humanReadableSize;
})->exceptOnForms(),
Text::make(__('Media Updated At'))->displayUsing(function () {
return $this->resource->updated_at->diffForHumans();
})->exceptOnForms(),
GeneratedConversions::make(__('Media Conversions')),
];
};
}
}