mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
Refactoring
This commit is contained in:
@@ -36,6 +36,6 @@ class CreateFileManagerFolders extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('file_manager_folders');
|
||||
Schema::dropIfExists('folders');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,6 @@ class CreateFileManagerFiles extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('file_manager_files');
|
||||
Schema::dropIfExists('files');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,13 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
/**
|
||||
* @property mixed id
|
||||
* @property Setting settings
|
||||
* @property string email
|
||||
* @property mixed favouriteFolders
|
||||
* @property string role
|
||||
* @method static count()
|
||||
* @method static sortable(string[] $array)
|
||||
* @method static forceCreate(array $array)
|
||||
* @method static where(string $string, string $string1, string $toDateString)
|
||||
*/
|
||||
class User extends Authenticatable implements MustVerifyEmail
|
||||
{
|
||||
|
||||
@@ -10,9 +10,8 @@ class DisabledMimetypes implements Rule
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
public function passes($attribute, $value): bool
|
||||
{
|
||||
$mimetype_blacklist = explode(',', get_setting('mimetypes_blacklist'));
|
||||
$file_mimetype = explode('/', $value->getMimeType());
|
||||
@@ -22,10 +21,8 @@ class DisabledMimetypes implements Rule
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
public function message(): string
|
||||
{
|
||||
return 'Type of this mime type is not allowed.';
|
||||
}
|
||||
|
||||
@@ -86,9 +86,9 @@ class UploadFileAction
|
||||
return UserFile::create([
|
||||
'mimetype' => get_file_type_from_mimetype($file_mimetype),
|
||||
'type' => get_file_type($file_mimetype),
|
||||
'folder_id' => $request->folder_id,
|
||||
'folder_id' => $request->input('folder_id'),
|
||||
'metadata' => $metadata,
|
||||
'name' => $request->filename,
|
||||
'name' => $request->input('filename'),
|
||||
'basename' => $disk_file_name,
|
||||
'author' => $shared ? 'visitor' : 'user',
|
||||
'thumbnail' => $thumbnail,
|
||||
|
||||
@@ -9,18 +9,22 @@ use Support\Demo\Actions\FakeUploadFileAction;
|
||||
|
||||
class UploadFileController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
public UploadFileAction $uploadFiles,
|
||||
public FakeUploadFileAction $fakeUploadFile,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Upload file for authenticated master|editor user
|
||||
*/
|
||||
public function __invoke(
|
||||
UploadRequest $request,
|
||||
UploadFileAction $uploadFiles,
|
||||
FakeUploadFileAction $fakeUploadFile,
|
||||
): File | array {
|
||||
|
||||
if (is_demo_account('howdy@hi5ve.digital')) {
|
||||
return ($fakeUploadFile)($request);
|
||||
return ($this->fakeUploadFile)($request);
|
||||
}
|
||||
|
||||
return ($uploadFiles)($request);
|
||||
return ($this->uploadFiles)($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class VisitorUploadFileController extends Controller
|
||||
}
|
||||
|
||||
// Check access to requested directory
|
||||
($this->verifyAccessToItem)($request->folder_id, $shared);
|
||||
($this->verifyAccessToItem)($request->input('folder_id'), $shared);
|
||||
|
||||
// Return new uploaded file
|
||||
$new_file = ($this->uploadFile)($request, $shared);
|
||||
|
||||
@@ -19,8 +19,23 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
/**
|
||||
* @method static whereUserId($user_id)
|
||||
* @method static whereId($id)
|
||||
* @property string folder_id
|
||||
* @method static find(mixed $id)
|
||||
* @method static where(string $string, string $user_id)
|
||||
* @property string id
|
||||
* @property string user_id
|
||||
* @property string folder_id
|
||||
* @property string thumbnail
|
||||
* @property string filesize
|
||||
* @property string type
|
||||
* @property array metadata
|
||||
* @property string basename
|
||||
* @property string name
|
||||
* @property string mimetype
|
||||
* @property string author
|
||||
* @property string author_id
|
||||
* @property string created_at
|
||||
* @property string updated_at
|
||||
* @property string deleted_at
|
||||
*/
|
||||
class File extends Model
|
||||
{
|
||||
@@ -47,7 +62,7 @@ class File extends Model
|
||||
'author_id',
|
||||
];
|
||||
|
||||
public $sortable = [
|
||||
public array $sortable = [
|
||||
'name',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Domain\Folders\Actions;
|
||||
|
||||
use Domain\Folders\Requests\CreateFolderRequest;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -11,14 +12,14 @@ class CreateFolderAction
|
||||
* Create new directory
|
||||
*/
|
||||
public function __invoke(
|
||||
$request,
|
||||
CreateFolderRequest $request,
|
||||
?Share $shared = null,
|
||||
): Folder | array {
|
||||
return Folder::create([
|
||||
'parent_id' => $request->parent_id,
|
||||
'name' => $request->name,
|
||||
'color' => $request->color ?? null,
|
||||
'emoji' => $request->emoji ?? null,
|
||||
'parent_id' => $request->input('parent_id'),
|
||||
'name' => $request->input('name'),
|
||||
'color' => $request->input('color') ?? null,
|
||||
'emoji' => $request->input('emoji') ?? null,
|
||||
'author' => $shared ? 'visitor' : 'user',
|
||||
'user_id' => $shared ? $shared->user_id : Auth::id(),
|
||||
]);
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
namespace Domain\Folders\Actions;
|
||||
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Domain\Items\Requests\RenameItemRequest;
|
||||
|
||||
class UpdateFolderPropertyAction
|
||||
{
|
||||
/**
|
||||
* Update folder icon or style
|
||||
*/
|
||||
public function __invoke($request, string $id): void
|
||||
public function __invoke(RenameItemRequest $request, string $id): void
|
||||
{
|
||||
// Get folder
|
||||
$folder = Folder::find($id);
|
||||
@@ -24,7 +25,7 @@ class UpdateFolderPropertyAction
|
||||
// Set emoji
|
||||
if ($request->filled('emoji')) {
|
||||
$folder->update([
|
||||
'emoji' => $request->emoji,
|
||||
'emoji' => $request->input('emoji'),
|
||||
'color' => null,
|
||||
]);
|
||||
}
|
||||
@@ -33,7 +34,7 @@ class UpdateFolderPropertyAction
|
||||
if ($request->filled('color')) {
|
||||
$folder->update([
|
||||
'emoji' => null,
|
||||
'color' => $request->color,
|
||||
'color' => $request->input('color'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,20 +10,24 @@ use Support\Demo\Actions\FakeCreateFolderAction;
|
||||
|
||||
class CreateFolderController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
public CreateFolderAction $createFolder,
|
||||
public FakeCreateFolderAction $fakeCreateFolder,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Create new folder for authenticated master|editor user
|
||||
*/
|
||||
public function __invoke(
|
||||
CreateFolderRequest $request,
|
||||
CreateFolderAction $createFolder,
|
||||
FakeCreateFolderAction $fakeCreateFolder,
|
||||
): Response | array {
|
||||
// If is demo, return fake folder
|
||||
if (is_demo_account(Auth::user()->email)) {
|
||||
return ($fakeCreateFolder)($request);
|
||||
return ($this->fakeCreateFolder)($request);
|
||||
}
|
||||
|
||||
$folder = ($createFolder)($request);
|
||||
// CreateFolder
|
||||
$folder = ($this->createFolder)($request);
|
||||
|
||||
return response($folder, 201);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,19 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
/**
|
||||
* @method static whereUserId(int|string|null $id)
|
||||
* @method static find(mixed $id)
|
||||
* @method static where(string $string, string $user_id)
|
||||
* @property string id
|
||||
* @property string user_id
|
||||
* @property string parent_id
|
||||
* @property string name
|
||||
* @property string color
|
||||
* @property string emoji
|
||||
* @property string author
|
||||
* @property string author_id
|
||||
* @property string created_at
|
||||
* @property string updated_at
|
||||
* @property string deleted_at
|
||||
*/
|
||||
class Folder extends Model
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Homepage\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
@@ -15,11 +16,13 @@ class SendContactMessageController extends Controller
|
||||
public function __invoke(
|
||||
SendContactMessageRequest $request
|
||||
): Response {
|
||||
Mail::to(
|
||||
get_setting('contact_email')
|
||||
)->send(
|
||||
new SendContactMessage($request->all())
|
||||
);
|
||||
|
||||
$contactEmail = get_setting('contact_email');
|
||||
|
||||
if ($contactEmail) {
|
||||
Mail::to($contactEmail)
|
||||
->send(new SendContactMessage($request->all()));
|
||||
}
|
||||
|
||||
return response('Done', 201);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Support\Arr;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Domain\Files\Models\File as UserFile;
|
||||
use Domain\Files\Models\File;
|
||||
|
||||
class DeleteFileOrFolderAction
|
||||
{
|
||||
@@ -52,7 +52,7 @@ class DeleteFileOrFolderAction
|
||||
$child_folders = filter_folders_ids($folder->trashedFolders, 'id');
|
||||
|
||||
// Get children files
|
||||
$files = UserFile::onlyTrashed()
|
||||
$files = File::onlyTrashed()
|
||||
->whereIn('folder_id', Arr::flatten([$id, $child_folders]))
|
||||
->get();
|
||||
|
||||
@@ -80,7 +80,7 @@ class DeleteFileOrFolderAction
|
||||
// Delete item
|
||||
if ($item['type'] !== 'folder') {
|
||||
// Get file
|
||||
$file = UserFile::withTrashed()
|
||||
$file = File::withTrashed()
|
||||
->find($id);
|
||||
|
||||
// Get folder shared record
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
namespace Domain\Items\Actions;
|
||||
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Domain\Files\Models\File as UserFile;
|
||||
use Domain\Files\Models\File;
|
||||
|
||||
class MoveFileOrFolderAction
|
||||
{
|
||||
@@ -20,7 +20,7 @@ class MoveFileOrFolderAction
|
||||
|
||||
// Move file
|
||||
if ($item['type'] !== 'folder') {
|
||||
UserFile::find($item['id'])
|
||||
File::find($item['id'])
|
||||
->update(['folder_id' => $to_id]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,21 +9,22 @@ use Domain\Items\Actions\DeleteFileOrFolderAction;
|
||||
|
||||
class DeleteFileOrFolderController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
public DeleteFileOrFolderAction $deleteFileOrFolder,
|
||||
){}
|
||||
|
||||
/**
|
||||
* Delete item for authenticated master|editor user
|
||||
*/
|
||||
public function __invoke(
|
||||
DeleteItemRequest $request,
|
||||
DeleteFileOrFolderAction $deleteFileOrFolder,
|
||||
): Response {
|
||||
abort_if(
|
||||
is_demo_account(Auth::user()?->email),
|
||||
204,
|
||||
'Done.'
|
||||
is_demo_account(Auth::user()?->email), 204, 'Done.'
|
||||
);
|
||||
|
||||
foreach ($request->input('items') as $item) {
|
||||
($deleteFileOrFolder)($item, $item['id']);
|
||||
($this->deleteFileOrFolder)($item, $item['id']);
|
||||
}
|
||||
|
||||
return response('Done', 204);
|
||||
|
||||
@@ -9,12 +9,15 @@ use Domain\Items\Actions\MoveFileOrFolderAction;
|
||||
|
||||
class MoveFileOrFolderController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
public MoveFileOrFolderAction $moveFileOrFolder,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Move item for authenticated master|editor user
|
||||
*/
|
||||
public function __invoke(
|
||||
MoveItemRequest $request,
|
||||
MoveFileOrFolderAction $moveFileOrFolder,
|
||||
): Response {
|
||||
abort_if(
|
||||
is_demo_account(Auth::user()?->email),
|
||||
@@ -22,10 +25,8 @@ class MoveFileOrFolderController extends Controller
|
||||
'Done.'
|
||||
);
|
||||
|
||||
($moveFileOrFolder)(
|
||||
$request,
|
||||
$request->input('to_id')
|
||||
);
|
||||
// Move item
|
||||
($this->moveFileOrFolder)($request, $request->input('to_id'));
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
@@ -11,26 +11,29 @@ use Support\Demo\Actions\FakeRenameFileOrFolderAction;
|
||||
|
||||
class RenameFileOrFolderController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
public RenameFileOrFolderAction $renameFileOrFolder,
|
||||
public UpdateFolderPropertyAction $updateFolderProperty,
|
||||
public FakeRenameFileOrFolderAction $fakeRenameFileOrFolder,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Rename item for authenticated master|editor user
|
||||
*/
|
||||
public function __invoke(
|
||||
RenameItemRequest $request,
|
||||
string $id,
|
||||
RenameFileOrFolderAction $renameFileOrFolder,
|
||||
UpdateFolderPropertyAction $updateFolderProperty,
|
||||
FakeRenameFileOrFolderAction $fakeRenameFileOrFolder,
|
||||
): Model | array {
|
||||
if (is_demo_account(Auth::user()->email)) {
|
||||
return ($fakeRenameFileOrFolder)($request, $id);
|
||||
return ($this->fakeRenameFileOrFolder)($request, $id);
|
||||
}
|
||||
|
||||
// If request contain icon or color, then change it
|
||||
if ($request->filled('emoji') || $request->filled('color')) {
|
||||
($updateFolderProperty)($request, $id);
|
||||
($this->updateFolderProperty)($request, $id);
|
||||
}
|
||||
|
||||
// Rename Item
|
||||
return ($renameFileOrFolder)($request, $id);
|
||||
return ($this->renameFileOrFolder)($request, $id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Domain\Localization\Actions;
|
||||
|
||||
|
||||
use DB;
|
||||
|
||||
class SeedDefaultLanguageTranslationsAction
|
||||
{
|
||||
public function __invoke(
|
||||
string $license,
|
||||
string $locale
|
||||
): void {
|
||||
$translations = [
|
||||
'extended' => collect([
|
||||
config('language-translations.extended'),
|
||||
config('language-translations.regular'),
|
||||
config('custom-language-translations'),
|
||||
])->collapse(),
|
||||
'regular' => collect([
|
||||
config('language-translations.regular'),
|
||||
config('custom-language-translations'),
|
||||
])->collapse(),
|
||||
];
|
||||
|
||||
$translations = $translations[strtolower($license)]
|
||||
->map(fn ($value, $key) => [
|
||||
'lang' => $locale,
|
||||
'value' => $value,
|
||||
'key' => $key,
|
||||
])->toArray();
|
||||
|
||||
$chunks = array_chunk($translations, 100);
|
||||
|
||||
foreach ($chunks as $chunk) {
|
||||
DB::table('language_translations')
|
||||
->insert($chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +1,20 @@
|
||||
<?php
|
||||
namespace Domain\Localization\Services;
|
||||
|
||||
|
||||
namespace Domain\Localization\Actions;
|
||||
|
||||
|
||||
use DB;
|
||||
use Domain\Localization\Models\Language;
|
||||
use Domain\Localization\Models\LanguageTranslation;
|
||||
|
||||
class LanguageService
|
||||
class UpgradeLanguageTranslationsAction
|
||||
{
|
||||
/**
|
||||
* @param $license
|
||||
* @param $locale
|
||||
*/
|
||||
public function create_default_language_translations($license, $locale)
|
||||
{
|
||||
$translations = [
|
||||
'extended' => collect([
|
||||
config('language-translations.extended'),
|
||||
config('language-translations.regular'),
|
||||
config('custom-language-translations'),
|
||||
])->collapse(),
|
||||
'regular' => collect([
|
||||
config('language-translations.regular'),
|
||||
config('custom-language-translations'),
|
||||
])->collapse(),
|
||||
];
|
||||
|
||||
$translations = $translations[strtolower($license)]
|
||||
->map(function ($value, $key) use ($locale) {
|
||||
return [
|
||||
'lang' => $locale,
|
||||
'value' => $value,
|
||||
'key' => $key,
|
||||
];
|
||||
})->toArray();
|
||||
|
||||
$chunks = array_chunk($translations, 100);
|
||||
|
||||
foreach ($chunks as $chunk) {
|
||||
DB::table('language_translations')
|
||||
->insert($chunk);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find newly added translations in default language
|
||||
* translations file and insert it into database
|
||||
*/
|
||||
public function upgrade_language_translations()
|
||||
public function __invoke(): void
|
||||
{
|
||||
// Get all app locales
|
||||
$locales = Language::all()
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Domain\Localization\Controllers;
|
||||
|
||||
use Domain\Localization\Actions\SeedDefaultLanguageTranslationsAction;
|
||||
use Illuminate\Http\Response;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
<?php
|
||||
namespace Domain\Localization\Models;
|
||||
|
||||
use Domain\Localization\Actions\SeedDefaultLanguageTranslationsAction;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Domain\Localization\Services\LanguageService;
|
||||
|
||||
/**
|
||||
* @method static whereLocale(string $param)
|
||||
* @method static create(string[] $array)
|
||||
* @property string id
|
||||
* @property string name
|
||||
* @property string locale
|
||||
* @property string created_at
|
||||
* @property string updated_at
|
||||
*/
|
||||
class Language extends Model
|
||||
{
|
||||
@@ -28,7 +35,7 @@ class Language extends Model
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public function languageTranslations()
|
||||
public function languageTranslations(): HasMany
|
||||
{
|
||||
return $this->hasMany(LanguageTranslation::class, 'lang', 'locale');
|
||||
}
|
||||
@@ -40,11 +47,10 @@ class Language extends Model
|
||||
static::creating(function ($language) {
|
||||
$language->id = Str::uuid();
|
||||
|
||||
resolve(LanguageService::class)
|
||||
->create_default_language_translations(
|
||||
get_setting('license') ?? 'extended',
|
||||
$language->locale
|
||||
);
|
||||
resolve(SeedDefaultLanguageTranslationsAction::class)(
|
||||
license: get_setting('license') ?? 'extended',
|
||||
locale: $language->locale
|
||||
);
|
||||
});
|
||||
|
||||
static::updating(function ($language) {
|
||||
|
||||
@@ -5,6 +5,10 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @method static whereLang(string $string)
|
||||
* @property string key
|
||||
* @property string value
|
||||
* @property string lang
|
||||
|
||||
*/
|
||||
class LanguageTranslation extends Model
|
||||
{
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
<?php
|
||||
namespace Domain\Maintenance\Controllers;
|
||||
|
||||
use Domain\Localization\Actions\UpgradeLanguageTranslationsAction;
|
||||
use Gate;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Localization\Services\LanguageService;
|
||||
|
||||
class UpgradeTranslationsController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
public UpgradeLanguageTranslationsAction $upgradeLanguageTranslations,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get new language translations from default translations
|
||||
* and insert it into database
|
||||
@@ -17,8 +21,7 @@ class UpgradeTranslationsController extends Controller
|
||||
// Check admin permission
|
||||
Gate::authorize('maintenance');
|
||||
|
||||
resolve(LanguageService::class)
|
||||
->upgrade_language_translations();
|
||||
($this->upgradeLanguageTranslations)();
|
||||
|
||||
return response('Done.', 201);
|
||||
}
|
||||
|
||||
@@ -5,16 +5,17 @@ use Kyslik\ColumnSortable\Sortable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
/**
|
||||
* @property string slug
|
||||
* @property string title
|
||||
* @property boolean visibility
|
||||
* @property string content
|
||||
*/
|
||||
class Page extends Model
|
||||
{
|
||||
use Sortable, HasFactory;
|
||||
|
||||
/**
|
||||
* Sortable columns
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $sortable = [
|
||||
public array $sortable = [
|
||||
'title',
|
||||
'slug',
|
||||
'visibility',
|
||||
|
||||
@@ -6,6 +6,13 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
/**
|
||||
* @method static whereName(string $string)
|
||||
* @method static updateOrCreate(array $array, array $array1)
|
||||
* @method static forceCreate(array $array)
|
||||
* @method static where(string $string, mixed $get)
|
||||
* @method static whereIn(string $string, string[] $columns)
|
||||
* @method static create(string[] $array)
|
||||
* @property string value
|
||||
* @property string name
|
||||
*/
|
||||
class Setting extends Model
|
||||
{
|
||||
|
||||
@@ -11,14 +11,14 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class SharePublicIndexController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show page index and delete share_session cookie
|
||||
*/
|
||||
public function __construct(
|
||||
public RecordDownloadAction $recordDownload,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Show page index and delete share_session cookie
|
||||
*/
|
||||
public function __invoke(
|
||||
Share $shared,
|
||||
): View | StreamedResponse {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
namespace Domain\Sharing\Models;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Support\Str;
|
||||
use Database\Factories\ShareFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -44,15 +45,13 @@ class Share extends Model
|
||||
|
||||
/**
|
||||
* Generate share link
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLinkAttribute()
|
||||
public function getLinkAttribute(): string
|
||||
{
|
||||
return url('/share', ['token' => $this->attributes['token']]);
|
||||
}
|
||||
|
||||
public function user()
|
||||
public function user(): HasOne
|
||||
{
|
||||
return $this->hasOne(User::class, 'id', 'user_id');
|
||||
}
|
||||
@@ -66,7 +65,7 @@ class Share extends Model
|
||||
|
||||
static::creating(function ($shared) {
|
||||
$shared->id = (string) Str::uuid();
|
||||
$shared->token = Str::random(16);
|
||||
$shared->token = Str::random();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,10 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
/**
|
||||
* @method static whereYear(string $string, string $string1, int $year)
|
||||
* @method static currentMonth()
|
||||
* @property string id
|
||||
* @property string user_id
|
||||
* @property integer upload
|
||||
* @property integer download
|
||||
*/
|
||||
class Traffic extends Model
|
||||
{
|
||||
|
||||
@@ -12,7 +12,9 @@ class DumpTrashController extends Controller
|
||||
{
|
||||
public function __invoke(): Response
|
||||
{
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done!');
|
||||
abort_if(
|
||||
is_demo_account(Auth::user()->email), 204, 'Done!'
|
||||
);
|
||||
|
||||
$user_id = Auth::id();
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ class VisitorZipFilesController extends Controller
|
||||
->whereIn('id', $request->items)
|
||||
->get();
|
||||
|
||||
// Create zip
|
||||
$zip = ($this->zipFiles)($files, $shared);
|
||||
|
||||
// Get file
|
||||
|
||||
@@ -39,6 +39,7 @@ class VisitorZipFolderController extends Controller
|
||||
abort(404, 'Requested folder doesn\'t exists.');
|
||||
}
|
||||
|
||||
// Create zip
|
||||
$zip = ($this->zipFolder)($id, $shared);
|
||||
|
||||
// Get file
|
||||
|
||||
@@ -9,7 +9,13 @@ use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
/**
|
||||
* @property mixed basename
|
||||
* @property string basename
|
||||
* @property string shared_token
|
||||
* @property string id
|
||||
* @property string user_id
|
||||
* @property string created_at
|
||||
* @property string updated_at
|
||||
* @method static where(string $string, string $string1, string $toDateTimeString)
|
||||
*/
|
||||
class Zip extends Model
|
||||
{
|
||||
|
||||
@@ -25,6 +25,6 @@ abstract class TestCase extends BaseTestCase
|
||||
|
||||
resolve(CreateDiskDirectoriesAction::class)();
|
||||
|
||||
//$this->withoutExceptionHandling();
|
||||
$this->withoutExceptionHandling();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user