mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-19 19:55:02 +00:00
add for backend send shared link via email
This commit is contained in:
@@ -117,4 +117,21 @@ class ShareController extends Controller
|
||||
// Done
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
public function shared_send_via_email (Request $request, $token)
|
||||
{
|
||||
$share = Share::where('token', $token)
|
||||
->where('user_id', Auth::id())
|
||||
->first();
|
||||
|
||||
// Demo preview
|
||||
if (env('APP_DEMO')) {
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
// Send share link via email
|
||||
$share->sendSharedLinkViaEmail($request->emails, $token);
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class SharedSendViaEmail extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($emails, $token)
|
||||
{
|
||||
$this->emails = $emails;
|
||||
$this->token = $token;
|
||||
$this->user = Auth::user();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$notifiable->email = $this->emails;
|
||||
$shared_link = url(env('APP_URL') . '/shared' . '/' . $this->token );
|
||||
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(__('vuefilemanager.reset_password_subject') . config('vuefilemanager.app_name'))
|
||||
->greeting(__('vuefilemanager.shared_link_email_greeting'))
|
||||
->line(__('vuefilemanager.shared_link_email_user', ['user' => $this->user->name, 'email' => $this->user->email]))
|
||||
->action(__('vuefilemanager.shared_link_email_link'), $shared_link);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Notifications\SharedSendViaEmail;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
/**
|
||||
* App\Share
|
||||
@@ -37,6 +39,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*/
|
||||
class Share extends Model
|
||||
{
|
||||
use Notifiable;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $appends = ['link'];
|
||||
@@ -50,4 +54,15 @@ class Share extends Model
|
||||
|
||||
return url('/shared', ['token' => $this->attributes['token']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the sahared link notification.
|
||||
*
|
||||
* @param string $token $emails
|
||||
* @return void
|
||||
*/
|
||||
public function sendSharedLinkViaEmail($emails, $token)
|
||||
{
|
||||
$this->notify(new SharedSendViaEmail($emails, $token));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user