Good evening, friends,
I'm having a problem, when I try to pass the variables from one control to another, it ends up accusing the variable "not defined":
(Undefined variable: schedule)
I do not know what I'm doing wrong, could anyone help me? I need a light rsrs ...
ScheduleController.php
use App\Schedule;
use App\Mail\AgendamentoEpcSup;
use Illuminate\Support\Facades\Mail;
public function store(Request $request)
{
$schedule = New Schedule();
$schedule->user_id = $request -> input('user_id');
$schedule->room_id = $request -> input('room_id');
$data_str = \DateTime::createFromFormat('d-m-Y', $request-> input ('date_choice'));
$schedule->date = $data_str->format('Y-m-d');
$schedule->hour_in = $request-> input('hour_in');
$schedule->hour_out = $request-> input('hour_out');
$schedule->save();
$user = Auth::user();
$user_email = Auth::user()->email;
Mail::to($user_email)->send(new AgendamentoEpcSup($schedule, $user));
return redirect()->route('schedules.index')->with('status', 'Novo agendamento criado, lembrando que cancelamentos só podem ser feitos com 12h de antecedência pelo sistema.');
}
SchedulingEpcSup.php
namespace App\Mail;
use App\User;
use App\Schedule;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class AgendamentoEpcSup extends Mailable
{
use Queueable, SerializesModels;
public $schedule;
public $user;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
$this->schedule = $schedule;
$this->user = $user;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('emails.agendamento', compact('schedule', 'user'));
}
}
I do not know why values are not being passed: /
Thank you in advance!