Ir para conteúdo
Fórum Script Brasil
  • 0

Envio de email com cópia


Álef Henrique

Pergunta

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 para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...