Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

alefhs2014

Envio com cópia - Errata

Recommended Posts

Boa tarde, não sou muito experiente com php. Estou iniciando nessa área agora!

É o seguinte preciso que o sistema envie um e-mail com cópia para um e-mail específico, já tentei de várias formas e não consigo, segue abaixo os arquivos ultilizados.

Se alguém poder me dar uma força.

 

Obrigado!

 

-----------------> UserMailer.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);
}
}
-----------------> ticketsController.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');
}
}

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.