v0.5.2
This commit is contained in:
commit
f2e6586969
134 files changed
+9705
No files matched your search
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace IriksIT\Manager\Modules\Media;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use IriksIT\Manager\Modules\BaseModule;
|
||||
use IriksIT\Manager\Support\Names;
|
||||
use IriksIT\Manager\Support\Permission;
|
||||
|
||||
class MediaModule extends BaseModule
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'media';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Media';
|
||||
}
|
||||
|
||||
public function enabledByDefault(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function tables(): array
|
||||
{
|
||||
return ['media'];
|
||||
}
|
||||
|
||||
public function permissions(): array
|
||||
{
|
||||
return [
|
||||
new Permission('media.view', 'See the media library and pick files from it', 'Media'),
|
||||
new Permission('media.upload', 'Upload files', 'Media', needs: ['media.view']),
|
||||
new Permission('media.edit', 'Change the name, description and focus point of a file', 'Media', needs: ['media.view']),
|
||||
new Permission('media.delete', 'Delete files', 'Media', needs: ['media.view']),
|
||||
];
|
||||
}
|
||||
|
||||
public function navigation(): array
|
||||
{
|
||||
return [
|
||||
['label' => 'Media', 'route' => Names::route('media.index'), 'permission' => 'media.view'],
|
||||
];
|
||||
}
|
||||
|
||||
public function actions(): array
|
||||
{
|
||||
return [
|
||||
'media.store' => ['Uploaded a file'],
|
||||
'media.update' => ['Changed a file'],
|
||||
'media.destroy' => ['Deleted a file'],
|
||||
];
|
||||
}
|
||||
|
||||
public function views(): array
|
||||
{
|
||||
return ['media.index' => 'Opened the media library', 'media.items' => ''];
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
RateLimiter::for('media-files', fn (Request $request) => Limit::perMinute(max(1, (int) config('manager.media.per_minute', 600)))->by((string) $request->ip()));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user