mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-29 19:25:57 +00:00
- gate implementation
- protected shared view fix
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace Domain\Folders\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Folders\Resources\FolderResource;
|
||||
@@ -22,13 +21,13 @@ class CreateFolderController extends Controller
|
||||
*/
|
||||
public function __invoke(
|
||||
CreateFolderRequest $request,
|
||||
): Response | array {
|
||||
// If is demo, return fake folder
|
||||
if (is_demo_account(Auth::user()->email)) {
|
||||
return ($this->fakeCreateFolder)($request);
|
||||
): Response {
|
||||
if (is_demo_account()) {
|
||||
$fakeFolder = ($this->fakeCreateFolder)($request);
|
||||
|
||||
return response(new FolderResource($fakeFolder), 201);
|
||||
}
|
||||
|
||||
// CreateFolder
|
||||
$folder = ($this->createFolder)($request);
|
||||
|
||||
return response(new FolderResource($folder), 201);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Folders\Controllers;
|
||||
|
||||
use Domain\Folders\Models\Folder;
|
||||
|
||||
@@ -27,7 +27,7 @@ class VisitorCreateFolderController extends Controller
|
||||
CreateFolderRequest $request,
|
||||
Share $shared,
|
||||
): Response | array {
|
||||
if (is_demo_account($shared->user->email)) {
|
||||
if (is_demo_account()) {
|
||||
return ($this->fakeCreateFolderAction)($request);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ class Folder extends Model
|
||||
*/
|
||||
public function files(): HasMany
|
||||
{
|
||||
return $this->hasMany(File::class, 'folder_id', 'id');
|
||||
return $this->hasMany(File::class, 'parent_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ class Folder extends Model
|
||||
*/
|
||||
public function trashedFiles(): HasMany
|
||||
{
|
||||
return $this->hasMany(File::class, 'folder_id', 'id')
|
||||
return $this->hasMany(File::class, 'parent_id', 'id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
@@ -187,12 +187,12 @@ class Folder extends Model
|
||||
|
||||
public function teamInvitations(): HasMany
|
||||
{
|
||||
return $this->hasMany(TeamFolderInvitation::class, 'folder_id', 'id');
|
||||
return $this->hasMany(TeamFolderInvitation::class, 'parent_id', 'id');
|
||||
}
|
||||
|
||||
public function teamMembers(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'team_folder_members', 'folder_id', 'user_id')
|
||||
return $this->belongsToMany(User::class, 'team_folder_members', 'parent_id', 'user_id')
|
||||
->withPivot('permission');
|
||||
}
|
||||
|
||||
@@ -206,10 +206,20 @@ class Folder extends Model
|
||||
return $this->parents()->with('teamRoot');
|
||||
}
|
||||
|
||||
public function getLatestParent()
|
||||
{
|
||||
if ($this->parent) {
|
||||
return $this->parent->getLatestParent();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toSearchableArray(): array
|
||||
{
|
||||
$name = mb_convert_encoding(
|
||||
mb_strtolower($this->name, 'UTF-8'), 'UTF-8'
|
||||
mb_strtolower($this->name, 'UTF-8'),
|
||||
'UTF-8'
|
||||
);
|
||||
|
||||
$trigram = (new TNTIndexer)
|
||||
|
||||
Reference in New Issue
Block a user