Jump to content
Fórum Script Brasil
  • 0

Envio de email com cópia


Álef Henrique

Question

Bom dia, sou novo na área.
Estou trabalhando em um sistema de chamados, só que peguei ele em andamento e estou meio perdido.
Preciso que o sistema envie um alerta quando o usuário abrir um chamado. Quando o usuário abri o chamado vai uma mensagem pro usuário, mais pra min não está chegando. Já tentei de tudo, se alguém poder me ajudar.
Segue abaixo os arquivos utilizados:
*************UserMailerInterface.php***********************
<?php
namespace Care\Mailers;
use Care\User;
interface UserMailerInterface
{
/**
* e-mail aos usuários
* @param User $user
* @return mixed
*/
public function welcome(User $user);
public function TicketOpened(User $user);
}
*************User.php***********************
<?php
namespace Care\Mailers\Swift;
use Care\Mailers\UserMailerInterface;
use Care\User;
class UserMailer extends Mailer implements UserMailerInterface
{
/**
* Send welcome email to new registered users
* @param User $user
* @return mixed|void
*/
public function welcome(User $user)
{
$view = 'emails.welcome';
$subject = 'Bem-vindo ao Sistema de Chamados TP Tech';
$data = [
'name' => $user->name
];
return $this->sendTo($user->email, $subject, $view, $data);
}
public function TicketOpened(User $user)
{
$view = 'emails.new-ticket';
$subject = 'Novo chamado foi inaugurado';
$data = [
'name' => $user->name
];
return $this->sendTo($user->email, $subject, $view, $data);
}
}
*************Mailer.php*********************
<?php
namespace Care\Mailers\Swift;
use Mail;
abstract class Mailer
{
/**
* Core Mailer
* @param $email
* @param $subject
* @param $view
* @param array $data
*/
public function sendTo($email, $subject, $view, $data = [])
{
Mail::queue($view, $data, function ($message) use ($email, $subject) {
$message->to($email)
->subject($subject);
});
}
}
*************TicketsControler.php*********************
<?php
namespace Client;
use Care\Forms\SubmitTicketForm;
use Care\Mailers\UserMailerInterface;
use Care\Repositories\TicketsRepositoryInterface;
use Care\Repositories\AttachmentsRepositoryInterface;
use Care\Repositories\UsersRepositoryInterface;
use Care\Facades\Uploader;
use BaseController;
use Illuminate\Support\Facades\Auth;
use View;
use Redirect;
use Input;
class TicketsController extends BaseController
{
protected $ticketForm;
protected $tickets;
protected $users;
protected $attachments;
protected $userMailer;
function __construct(SubmitTicketForm $ticketForm,
TicketsRepositoryInterface $tickets,
AttachmentsRepositoryInterface $attachments,
UserMailerInterface $mailer,
UsersRepositoryInterface $users)
{
$this->ticketForm = $ticketForm;
$this->users = $users;
$this->tickets = $tickets;
$this->attachments = $attachments;
$this->userMailer = $mailer;
}
/**
* Display all tickets
* @return \Illuminate\View\View
*/
public function getIndex()
{
$tickets = $this->tickets->getUserTickets(Auth::user()->id);
return View::make('tickets.index', compact('clients', 'tickets'));
}
/**
* Display resolved tickets
* @return \Illuminate\View\View
*/
public function getResolved()
{
$tickets = $this->tickets->getUserClosedTickets(Auth::user()->id);
return View::make('tickets.index', compact('clients', 'tickets'));
}
/**
* Display resolved tickets
* @return \Illuminate\View\View
*/
public function getOpen()
{
$tickets = $this->tickets->getUserOpenTickets(Auth::user()->id);
return View::make('tickets.index', compact('clients', 'tickets'));
}
/**
* Process submission a new ticket
* @return mixed
*/
public function postTicket()
{
$this->ticketForm->validate(Input::all());
// Handle attachments
if (Input::hasFile('attachment')) {
$attachmendId = Uploader::attach(Input::file('attachment'));
}
$ticket = $this->tickets->getNew([
'title' => Input::get('title'),
'content' => Input::get('content'),
'client' => Auth::user()->id,
'attachment_id' => isset($attachmendId) ? $attachmendId : null,
'status' => 0
]);
$client = $this->users->getById(Auth::user()->id);
$this->userMailer->TicketOpened($client);
$this->tickets->save($ticket);
return Redirect::back()->withMessage('Chamado enviado com sucesso');
}
}
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.1k
    • Total Posts
      652k
×
×
  • Create New...