mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-25 10:20:38 +00:00
create team folder
This commit is contained in:
@@ -4,7 +4,6 @@ namespace Domain\Browsing\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use Domain\Files\Models\File;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class BrowseFolderController
|
||||
|
||||
@@ -14,7 +14,6 @@ class BrowseTrashContentController
|
||||
$requestedFolder = $root_id ? Folder::withTrashed()->findOrFail($root_id) : null;
|
||||
|
||||
if ($root_id) {
|
||||
|
||||
// Get folders and files
|
||||
$folders = Folder::onlyTrashed()
|
||||
->with('parent')
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace Domain\Browsing\Controllers;
|
||||
use Domain\Files\Models\File;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Illuminate\Support\Collection;
|
||||
use Domain\Sharing\Actions\ProtectShareRecordAction;
|
||||
use Domain\Sharing\Actions\VerifyAccessToItemAction;
|
||||
|
||||
@@ -23,7 +22,6 @@ class VisitorBrowseFolderController
|
||||
string $id,
|
||||
Share $shared,
|
||||
): array {
|
||||
|
||||
// Check ability to access protected share record
|
||||
($this->protectShareRecord)($shared);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
* @method static find(mixed $id)
|
||||
* @method static where(string $string, string $user_id)
|
||||
* @method static findOrFail(string $root_id)
|
||||
* @method static create(array $array)
|
||||
* @property string id
|
||||
* @property string user_id
|
||||
* @property string parent_id
|
||||
@@ -31,6 +32,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
* @property string created_at
|
||||
* @property string updated_at
|
||||
* @property string deleted_at
|
||||
* @property bool team_folder
|
||||
*/
|
||||
class Folder extends Model
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace Domain\Sharing\Actions;
|
||||
|
||||
use Spatie\QueueableAction\QueueableAction;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Domain\Sharing\Notifications\SharedSendViaEmail;
|
||||
use Domain\Teams\Notifications\SharedSendViaEmail;
|
||||
|
||||
class SendViaEmailAction
|
||||
{
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace Domain\Teams\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Domain\Teams\DTO\CreateTeamFolderData;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Domain\Teams\Models\TeamFoldersInvitation;
|
||||
use Domain\Teams\Notifications\InvitationIntoTeamFolder;
|
||||
|
||||
class TeamFoldersController extends Controller
|
||||
{
|
||||
public function store(Request $request): Response
|
||||
{
|
||||
$data = CreateTeamFolderData::fromRequest($request);
|
||||
|
||||
$teamFolder = Folder::create([
|
||||
'user_id' => $request->user()->id,
|
||||
'name' => $data->name,
|
||||
'team_folder' => 1,
|
||||
]);
|
||||
|
||||
collect($data->members)
|
||||
->each(function ($email) use ($teamFolder) {
|
||||
|
||||
// Create invitation
|
||||
$invitation = TeamFoldersInvitation::create([
|
||||
'folder_id' => $teamFolder->id,
|
||||
'email' => $email,
|
||||
]);
|
||||
|
||||
// Invite user
|
||||
Notification::route('mail', $email)
|
||||
->notify(new InvitationIntoTeamFolder($teamFolder, $invitation));
|
||||
});
|
||||
|
||||
return response($teamFolder, 201);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace Domain\Teams\DTO;
|
||||
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
|
||||
class CreateTeamFolderData extends DataTransferObject
|
||||
{
|
||||
public string $name;
|
||||
public array $members;
|
||||
|
||||
public static function fromRequest($request): self
|
||||
{
|
||||
return new self([
|
||||
'name' => $request->input('name'),
|
||||
'members' => $request->input('members'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace Domain\Teams\Models;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
/**
|
||||
* @method static create(array $array)
|
||||
* @property string id
|
||||
* @property string folder_id
|
||||
* @property string email
|
||||
* @property string status
|
||||
* @property string created_at
|
||||
* @property string updated_at
|
||||
*/
|
||||
class TeamFoldersInvitation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $casts = [
|
||||
'id' => 'string',
|
||||
];
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
$model->id = Str::uuid();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace Domain\Teams\Notifications;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Domain\Teams\Models\TeamFoldersInvitation;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class InvitationIntoTeamFolder extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public Folder $teamFolder,
|
||||
public TeamFoldersInvitation $invitation,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*/
|
||||
public function via(): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$appTitle = get_settings('app_title') ?? 'VueFileManager';
|
||||
|
||||
$user = User::find($this->invitation->email);
|
||||
|
||||
if ($user) {
|
||||
return (new MailMessage)
|
||||
->subject("You are invited to collaboration with team folder in $appTitle")
|
||||
->greeting('Hello!')
|
||||
->line('You are invited to collaboration with team folder')
|
||||
->action('Join into Team Folder', url('/team-folder-invitation', ['id' => $this->invitation->id]))
|
||||
->salutation("Regards, $appTitle");
|
||||
}
|
||||
|
||||
return (new MailMessage)
|
||||
->subject("You are invited to collaboration with team folder in $appTitle")
|
||||
->greeting('Hello!')
|
||||
->line('You are invited to collaboration with team folder. But at first, you have to create an account to proceed into team folder.')
|
||||
->action('Join & Create an Account', url('/team-folder-invitation', ['id' => $this->invitation->id]))
|
||||
->salutation("Regards, $appTitle");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user