Laravel upgrade to version 8 throws error - laravel

I have just upgraded to version 8 and get this error in logs when I start the artisan serv service. Do you have any advice on what to do?
I submit the error that is thrown:
local.ERROR: Argument 1 passed to Illuminate\Cookie\Middleware\EncryptCookies::encrypt() must be an instance of Symfony\Component\HttpFoundation\Response, null given, called in C:\xampp\htdocs\vipa\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\EncryptCookies.php on line 67 {"exception":"[object] (TypeError(code: 0): Argument 1 passed to Illuminate\\Cookie\\Middleware\\EncryptCookies::encrypt() must be an instance of Symfony\\Component\\HttpFoundation\\Response, null given, called in C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\EncryptCookies.php on line 67 at C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\EncryptCookies.php:138)
[stacktrace]
#0 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\EncryptCookies.php(67): Illuminate\\Cookie\\Middleware\\EncryptCookies->encrypt(NULL)
#1 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#2 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#3 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(697): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#4 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(672): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#5 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(636): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#6 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(625): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#7 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(167): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#8 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#9 C:\\xampp\\htdocs\\vipa\\vendor\\fideloper\\proxy\\src\\TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#10 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#11 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#12 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#13 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#14 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#15 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#16 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#17 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#18 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#19 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#20 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#21 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#22 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(142): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#23 C:\\xampp\\htdocs\\vipa\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(111): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#24 C:\\xampp\\htdocs\\vipa\\public\\index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#25 C:\\xampp\\htdocs\\vipa\\server.php(21): require_once('C:\\\\xampp\\\\htdocs...')
#26 {main}
"}
17/11/2021
I managed to solve it by modifying the Handler class in this way:
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* #var string[]
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* #var string[]
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* #return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
}
and adding on the Routeserviceprovider the constant Home:
public const HOME = '/home';
Thanks anyway for the support

Related

Laravel Notification "Cannot unpack array with string keys" when implements ShouldQueue

I want to send Notification using Queues in Laravel Framework 6.18.20.
$user->notify( new UserRegistrationSMSSend(
$user->phone,
$user->getMeta('phone_verification_code')
));
I created notification named "UserRegistrationSMSSend".
<?php
namespace App\Notifications;
use App\Channels\SMSChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
class UserRegistrationSMSSend extends Notification implements ShouldQueue
{
use Queueable;
private $phone;
private $code;
/**
* Create a new notification instance.
*
* #return void
*/
public function __construct($phone, $code)
{
$this->phone = $phone;
$this->code = $code;
}
/**
* Get the notification's delivery channels.
*
* #param mixed $notifiable
* #return array
*/
public function via($notifiable)
{
return [SMSChannel::class];
}
/**
* Get the sms representation of the notification.
*
* #param mixed $notifiable
* #return \Illuminate\Notifications\Messages\MailMessage
*/
public function toSMS($notifiable)
{
if (\App::environment('production')) {
\LaravelLsimSms::sendSms(
$this->phone,
__('Code is :code', ['code'=>$this->code])
);
}
}
/**
* Get the array representation of the notification.
*
* #param mixed $notifiable
* #return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
When I'm calling this function result is "Cannot unpack array with string keys"
When I'm commenting out implements ShouldQueue it's working. What is the problem actually? Need your help.
Updated
This is the full log of returned error. And CACHE_DRIVER in .env file is array
[2020-06-02 06:08:53] local.ERROR: Cannot unpack array with string keys {"userId":11,"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Cannot unpack array with string keys at C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Collection.php:571)
[stacktrace]
#0 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Model.php(1430): Illuminate\\Database\\Eloquent\\Collection->getQueueableRelations()
#1 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\SerializesAndRestoresModelIdentifiers.php(35): Illuminate\\Database\\Eloquent\\Model->getQueueableRelations()
#2 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\SerializesModels.php(23): Illuminate\\Notifications\\SendQueuedNotifications->getSerializedPropertyValue(Object(App\\User))
#3 [internal function]: Illuminate\\Notifications\\SendQueuedNotifications->__sleep()
#4 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Queue.php(139): serialize(Object(Illuminate\\Notifications\\SendQueuedNotifications))
#5 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Queue.php(110): Illuminate\\Queue\\Queue->createObjectPayload(Object(Illuminate\\Notifications\\SendQueuedNotifications), NULL)
#6 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Queue.php(88): Illuminate\\Queue\\Queue->createPayloadArray(Object(Illuminate\\Notifications\\SendQueuedNotifications), NULL, '')
#7 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\SyncQueue.php(40): Illuminate\\Queue\\Queue->createPayload(Object(Illuminate\\Notifications\\SendQueuedNotifications), NULL, '')
#8 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Bus\\Dispatcher.php(182): Illuminate\\Queue\\SyncQueue->push(Object(Illuminate\\Notifications\\SendQueuedNotifications))
#9 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Bus\\Dispatcher.php(158): Illuminate\\Bus\\Dispatcher->pushCommandToQueue(Object(Illuminate\\Queue\\SyncQueue), Object(Illuminate\\Notifications\\SendQueuedNotifications))
#10 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Bus\\Dispatcher.php(73): Illuminate\\Bus\\Dispatcher->dispatchToQueue(Object(Illuminate\\Notifications\\SendQueuedNotifications))
#11 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\NotificationSender.php(201): Illuminate\\Bus\\Dispatcher->dispatch(Object(Illuminate\\Notifications\\SendQueuedNotifications))
#12 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\NotificationSender.php(76): Illuminate\\Notifications\\NotificationSender->queueNotification(Object(Illuminate\\Database\\Eloquent\\Collection), Object(App\\Notifications\\OrderStatusChanged))
#13 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\ChannelManager.php(39): Illuminate\\Notifications\\NotificationSender->send(Object(Illuminate\\Database\\Eloquent\\Collection), Object(App\\Notifications\\OrderStatusChanged))
#14 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\RoutesNotifications.php(18): Illuminate\\Notifications\\ChannelManager->send(Object(App\\User), Object(App\\Notifications\\OrderStatusChanged))
#15 C:\\xampp\\htdocs\\onlinehisse\\app\\Http\\Controllers\\OrderStatusController.php(93): App\\User->notify(Object(App\\Notifications\\OrderStatusChanged))
#16 [internal function]: App\\Http\\Controllers\\OrderStatusController->setOrderStatus(Object(App\\Http\\Requests\\SellerOrderStatusStoreRequest))
#17 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php(54): call_user_func_array(Array, Array)
#18 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('setOrderStatus', Array)
#19 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(219): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\OrderStatusController), 'setOrderStatus')
#20 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(176): Illuminate\\Routing\\Route->runController()
#21 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(681): Illuminate\\Routing\\Route->run()
#22 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(130): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#23 C:\\xampp\\htdocs\\onlinehisse\\app\\Http\\Middleware\\IsSeller.php(19): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#24 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): App\\Http\\Middleware\\IsSeller->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#25 C:\\xampp\\htdocs\\onlinehisse\\vendor\\tymon\\jwt-auth\\src\\Http\\Middleware\\Authenticate.php(32): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#26 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Tymon\\JWTAuth\\Http\\Middleware\\Authenticate->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#27 C:\\xampp\\htdocs\\onlinehisse\\app\\Http\\Middleware\\Localization.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#28 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): App\\Http\\Middleware\\Localization->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#31 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#32 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(683): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#33 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(658): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#34 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(624): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#35 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(613): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#36 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(170): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#37 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(130): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#38 C:\\xampp\\htdocs\\onlinehisse\\vendor\\barryvdh\\laravel-cors\\src\\HandleCors.php(36): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#39 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Barryvdh\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#40 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#41 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#42 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#43 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#44 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#45 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#46 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#47 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#48 C:\\xampp\\htdocs\\onlinehisse\\vendor\\fideloper\\proxy\\src\\TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#49 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#50 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#51 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(145): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#52 C:\\xampp\\htdocs\\onlinehisse\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#53 C:\\xampp\\htdocs\\onlinehisse\\public\\index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#54 {main}
"}
Thank you in advance

Laravel one of mail sending jobs do not work

I have 3 different jobs that are pushed to queue to send mail (News, Welcome, ResetPassword).
News and Welcome works fine, so I created last one identically but it throws error in storage/framework/views that the variables I am sending are undefined, which is not true because I did dd() before dispatch() to see if variables are set.
I am using queue with database driver and supervisor
Controller:
public function sendRecoverLink(Request $request) {
$this->validate($request, [
'email' => 'required|email'
]);
$user = User::where([
'email' => $request->email,
])->first();
if (! $user){
return response(['Message' => "No such user"], 403);
}
$url = URL::current(); //some url as example
//token crypting and inserting to database
dispatch(new SendResetEmail($user, $url)); //sends mail
return response(['message' => 'Send'], 200);
}
Job class
class SendResetEmail extends Job
{
protected $user;
protected $url;
/**
* Create a new job instance.
*
* #return void
*/
public function __construct($user, $url)
{
$this->user = $user;
$this->url = $url;
}
/**
* Execute the job.
*
* #return void
*/
public function handle()
{
Mail::to($this->user->email)->send(new Reset($this->user->first_name, $url));
}
}
Mail class
class Reset extends Mailable
{
use Queueable, SerializesModels;
protected $user;
protected $url;
/**
* Create a new message instance.
*
* #return void
*/
public function __construct(User $user, $url)
{
$this->user = $user;
$this->url = $url;
}
/**
* Build the message.
*
* #return $this
*/
public function build()
{
return $this->markdown('emails.reset')
->with([
'name' => $this->user->first_name,
'link' => $this->url,
]);
}
}
view
#component('mail::message')
# {{$name}},
reset your password by clicking this link{{$link}}
#endcomponent
Error in database
ErrorException: Undefined variable: user in /var/www/eventmanager/storage/framework/views/03cb8c67266d078a3839b8266816206d466825f2.php:2
Stack trace:
#0 /var/www/eventmanager/storage/framework/views/03cb8c67266d078a3839b8266816206d466825f2.php(2): Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(8, 'Undefined varia...', '/var/www/eventm...', 2, Array)
#1 /var/www/eventmanager/vendor/illuminate/view/Engines/PhpEngine.php(43): include('/var/www/eventm...')
#2 /var/www/eventmanager/vendor/illuminate/view/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/var/www/eventm...', Array)
#3 /var/www/eventmanager/vendor/illuminate/view/View.php(137): Illuminate\View\Engines\CompilerEngine->get('/var/www/eventm...', Array)
#4 /var/www/eventmanager/vendor/illuminate/view/View.php(120): Illuminate\View\View->getContents()
#5 /var/www/eventmanager/vendor/illuminate/view/View.php(85): Illuminate\View\View->renderContents()
#6 /var/www/eventmanager/vendor/illuminate/mail/Markdown.php(61): Illuminate\View\View->render()
#7 /var/www/eventmanager/vendor/illuminate/mail/Mailable.php(217): Illuminate\Mail\Markdown->render('emails.reset', Array)
#8 /var/www/eventmanager/vendor/illuminate/mail/Mailable.php(189): Illuminate\Mail\Mailable->buildMarkdownView()
#9 /var/www/eventmanager/vendor/illuminate/mail/Mailable.php(119): Illuminate\Mail\Mailable->buildView()
#10 /var/www/eventmanager/vendor/illuminate/mail/Mailer.php(250): Illuminate\Mail\Mailable->send(Object(Illuminate\Mail\Mailer))
#11 /var/www/eventmanager/vendor/illuminate/mail/Mailer.php(205): Illuminate\Mail\Mailer->sendMailable(Object(App\Mail\Reset))
#12 /var/www/eventmanager/vendor/illuminate/mail/PendingMail.php(99): Illuminate\Mail\Mailer->send(Object(App\Mail\Reset))
#13 /var/www/eventmanager/app/Jobs/SendResetEmail.php(28): Illuminate\Mail\PendingMail->send(Object(App\Mail\Reset))
#14 [internal function]: App\Jobs\SendResetEmail->handle()
#15 /var/www/eventmanager/vendor/illuminate/container/BoundMethod.php(29): call_user_func_array(Array, Array)
#16 /var/www/eventmanager/vendor/illuminate/container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#17 /var/www/eventmanager/vendor/illuminate/container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Laravel\Lumen\Application), Array, Object(Closure))
#18 /var/www/eventmanager/vendor/illuminate/container/Container.php(549): Illuminate\Container\BoundMethod::call(Object(Laravel\Lumen\Application), Array, Array, NULL)
#19 /var/www/eventmanager/vendor/illuminate/bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#20 /var/www/eventmanager/vendor/illuminate/pipeline/Pipeline.php(114): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(App\Jobs\SendResetEmail))
#21 /var/www/eventmanager/vendor/illuminate/pipeline/Pipeline.php(102): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(App\Jobs\SendResetEmail))
#22 /var/www/eventmanager/vendor/illuminate/bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#23 /var/www/eventmanager/vendor/illuminate/queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(App\Jobs\SendResetEmail), false)
#24 /var/www/eventmanager/vendor/illuminate/queue/Jobs/Job.php(76): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
#25 /var/www/eventmanager/vendor/illuminate/queue/Worker.php(320): Illuminate\Queue\Jobs\Job->fire()
#26 /var/www/eventmanager/vendor/illuminate/queue/Worker.php(270): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), Object(Illuminate\Queue\WorkerOptions))
#27 /var/www/eventmanager/vendor/illuminate/queue/Worker.php(114): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\DatabaseJob), 'database', Object(Illuminate\Queue\WorkerOptions))
#28 /var/www/eventmanager/vendor/illuminate/queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#29 /var/www/eventmanager/vendor/illuminate/queue/Console/WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')
#30 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
#31 /var/www/eventmanager/vendor/illuminate/container/BoundMethod.php(29): call_user_func_array(Array, Array)
#32 /var/www/eventmanager/vendor/illuminate/container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#33 /var/www/eventmanager/vendor/illuminate/container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Laravel\Lumen\Application), Array, Object(Closure))
#34 /var/www/eventmanager/vendor/illuminate/container/Container.php(549): Illuminate\Container\BoundMethod::call(Object(Laravel\Lumen\Application), Array, Array, NULL)
#35 /var/www/eventmanager/vendor/illuminate/console/Command.php(183): Illuminate\Container\Container->call(Array)
#36 /var/www/eventmanager/vendor/symfony/console/Command/Command.php(252): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#37 /var/www/eventmanager/vendor/illuminate/console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#38 /var/www/eventmanager/vendor/symfony/console/Application.php(946): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#39 /var/www/eventmanager/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#40 /var/www/eventmanager/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#41 /var/www/eventmanager/vendor/illuminate/console/Application.php(88): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#42 /var/www/eventmanager/vendor/laravel/lumen-framework/src/Console/Kernel.php(84): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#43 /var/www/eventmanager/artisan(35): Laravel\Lumen\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#44 {main}
Next ErrorException: Undefined variable: user (View: /var/www/eventmanager/resources/views/emails/reset.blade.php) in /var/www/eventmanager/storage/framework/views/03cb8c67266d078a3839b8266816206d466825f2.php:2
Stack trace:
#0 /var/www/eventmanager/vendor/illuminate/view/Engines/PhpEngine.php(45): Illuminate\View\Engines\CompilerEngine->handleViewException(Object(ErrorException), 0)
#1 /var/www/eventmanager/vendor/illuminate/view/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/var/www/eventm...', Array)
#2 /var/www/eventmanager/vendor/illuminate/view/View.php(137): Illuminate\View\Engines\CompilerEngine->get('/var/www/eventm...', Array)
#3 /var/www/eventmanager/vendor/illuminate/view/View.php(120): Illuminate\View\View->getContents()
#4 /var/www/eventmanager/vendor/illuminate/view/View.php(85): Illuminate\View\View->renderContents()
#5 /var/www/eventmanager/vendor/illuminate/mail/Markdown.php(61): Illuminate\View\View->render()
#6 /var/www/eventmanager/vendor/illuminate/mail/Mailable.php(217): Illuminate\Mail\Markdown->render('emails.reset', Array)
#7 /var/www/eventmanager/vendor/illuminate/mail/Mailable.php(189): Illuminate\Mail\Mailable->buildMarkdownView()
#8 /var/www/eventmanager/vendor/illuminate/mail/Mailable.php(119): Illuminate\Mail\Mailable->buildView()
#9 /var/www/eventmanager/vendor/illuminate/mail/Mailer.php(250): Illuminate\Mail\Mailable->send(Object(Illuminate\Mail\Mailer))
#10 /var/www/eventmanager/vendor/illuminate/mail/Mailer.php(205): Illuminate\Mail\Mailer->sendMailable(Object(App\Mail\Reset))
#11 /var/www/eventmanager/vendor/illuminate/mail/PendingMail.php(99): Illuminate\Mail\Mailer->send(Object(App\Mail\Reset))
#12 /var/www/eventmanager/app/Jobs/SendResetEmail.php(28): Illuminate\Mail\PendingMail->send(Object(App\Mail\Reset))
#13 [internal function]: App\Jobs\SendResetEmail->handle()
#14 /var/www/eventmanager/vendor/illuminate/container/BoundMethod.php(29): call_user_func_array(Array, Array)
#15 /var/www/eventmanager/vendor/illuminate/container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#16 /var/www/eventmanager/vendor/illuminate/container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Laravel\Lumen\Application), Array, Object(Closure))
#17 /var/www/eventmanager/vendor/illuminate/container/Container.php(549): Illuminate\Container\BoundMethod::call(Object(Laravel\Lumen\Application), Array, Array, NULL)
#18 /var/www/eventmanager/vendor/illuminate/bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#19 /var/www/eventmanager/vendor/illuminate/pipeline/Pipeline.php(114): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(App\Jobs\SendResetEmail))
#20 /var/www/eventmanager/vendor/illuminate/pipeline/Pipeline.php(102): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(App\Jobs\SendResetEmail))
#21 /var/www/eventmanager/vendor/illuminate/bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#22 /var/www/eventmanager/vendor/illuminate/queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(App\Jobs\SendResetEmail), false)
#23 /var/www/eventmanager/vendor/illuminate/queue/Jobs/Job.php(76): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
#24 /var/www/eventmanager/vendor/illuminate/queue/Worker.php(320): Illuminate\Queue\Jobs\Job->fire()
#25 /var/www/eventmanager/vendor/illuminate/queue/Worker.php(270): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), Object(Illuminate\Queue\WorkerOptions))
#26 /var/www/eventmanager/vendor/illuminate/queue/Worker.php(114): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\DatabaseJob), 'database', Object(Illuminate\Queue\WorkerOptions))
#27 /var/www/eventmanager/vendor/illuminate/queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#28 /var/www/eventmanager/vendor/illuminate/queue/Console/WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')
#29 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
#30 /var/www/eventmanager/vendor/illuminate/container/BoundMethod.php(29): call_user_func_array(Array, Array)
#31 /var/www/eventmanager/vendor/illuminate/container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#32 /var/www/eventmanager/vendor/illuminate/container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Laravel\Lumen\Application), Array, Object(Closure))
#33 /var/www/eventmanager/vendor/illuminate/container/Container.php(549): Illuminate\Container\BoundMethod::call(Object(Laravel\Lumen\Application), Array, Array, NULL)
#34 /var/www/eventmanager/vendor/illuminate/console/Command.php(183): Illuminate\Container\Container->call(Array)
#35 /var/www/eventmanager/vendor/symfony/console/Command/Command.php(252): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#36 /var/www/eventmanager/vendor/illuminate/console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#37 /var/www/eventmanager/vendor/symfony/console/Application.php(946): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#38 /var/www/eventmanager/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#39 /var/www/eventmanager/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#40 /var/www/eventmanager/vendor/illuminate/console/Application.php(88): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#41 /var/www/eventmanager/vendor/laravel/lumen-framework/src/Console/Kernel.php(84): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#42 /var/www/eventmanager/artisan(35): Laravel\Lumen\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#43 {main}
Queue was running old code for some reason, what I had to do was php artisan queue:restart and it was fixed

laravel framework logs multiple errors

i recently bought a dating script .. but nobody responds to technical support to solve some bugs in the platform. Can you help me? I get the following errors in logs and I do not know whether it will affect me or will affect me along the way. Thank you!
[2017-10-01 20:44:34] production.ERROR: exception 'Illuminate\Session\TokenMismatchException' in /home/webclasseu/webapps/interface/app/Http/Middleware/VerifyCsrfToken.php:43
Stack trace:
#0 [internal function]: App\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#1 /home/webclasseu/webapps/interface/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#2 /home/webclasseu/webapps/interface/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#3 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#4 /home/webclasseu/webapps/interface/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#5 /home/webclasseu/webapps/interface/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#6 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#7 /home/webclasseu/webapps/interface/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#8 /home/webclasseu/webapps/interface/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#9 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#10 /home/webclasseu/webapps/interface/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#11 /home/webclasseu/webapps/interface/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#12 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#13 /home/webclasseu/webapps/interface/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#14 /home/webclasseu/webapps/interface/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#15 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#16 /home/webclasseu/webapps/interface/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#17 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#18 /home/webclasseu/webapps/interface/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#19 /home/webclasseu/webapps/interface/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(122): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#20 /home/webclasseu/webapps/interface/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(87): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#21 /home/webclasseu/webapps/interface/app/Plugins/WebsocketChatPlugin/WebsocketServer/ServerConfigurationAutoloader.php(13): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#22 /home/webclasseu/webapps/interface/app/Plugins/WebsocketChatPlugin/WebsocketServer/Server.php(12): require_once('/home/webclasse...')
#23 {main}
In /home/webclasseu/webapps/interface/app/Http/Middleware/VerifyCsrfToken.php
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
use Closure;
use Illuminate\Support\Str;
use Symfony\Component\HttpFoundation\Cookie;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Session\TokenMismatchException;
class VerifyCsrfToken extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* #var array
*/
protected $except = [
'/pages/upload/image',
'/plugin/upload/email/image',
"testing/*",
"paypal",
"charge",
"paymentwall_charge",
"credits_callback",
"superpower_callback",
"superpower_charge"
];
public function handle($request, Closure $next)
{
$except_routes = \App\Components\Plugin::getCSRFRemoveRoutes();
$this->except = array_merge($this->except, $except_routes);
if ($this->isReading($request) || $this->shouldPassThrough($request) || $this->tokensMatch($request)) {
return $this->addCookieToResponse($request, $next($request));
}
throw new TokenMismatchException;
}
}

How can I inject "customer session" model in an observer in Magento 2

I am having trouble injecting the \Magento\Customer\Model\Session model into my observer. I am getting a "Circular dependency" error. Any ideas?
The idea is to force login on all frontend pages. I have successfully injected the URL interface to get the current URL and the HTTP class to redirect guest users to the login page.
The only missing piece now is the customer session model.
Here is my code:
<?php
/**
* Namespace
*/
namespace VendorName\CustomerLoginRedirect\Observer;
/**
* Dependencies
*/
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;
/**
* Observer Class
*/
class CustomerInit implements ObserverInterface {
/**
* Constructor
*/
protected $_url;
protected $_http;
protected $_session;
public function __construct(
\Magento\Framework\UrlInterface $url,
\Magento\Customer\Model\Session $session,
\Magento\Framework\App\Response\Http $http
) {
$this->_url = $url;
$this->_session = $session;
$this->_http = $http;
}
/**
* Manages redirect
*/
public function execute(Observer $observer) {
$url = $this->_url->getCurrentUrl();
$path = parse_url($url, PHP_URL_PATH);
// Allowed strings to match against URL
$allow = [
'/customer'
];
// Ignore customer pages
foreach ($allow as $s) {
if (stripos($path, $s) !== false) {
return;
}
}
// Check if customer logged in
// if ( $this->_session->isLoggedIn() ) {
// die('Is logged in!!');
// return;
// }
return;
// Redirect to login
$this->_http->setRedirect( $this->_url->getBaseUrl().'customer/account/login/', 301 );
}
}
Here is the error message:
Circular dependency: VendorName\CustomerLoginRedirect\Observer\CustomerInit depends on VendorName\CustomerLoginRedirect\Observer\CustomerInit and vice versa.
#0 /home/user/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('VendorName\\Custo...')
#1 /home/user/public_html/vendor/magento/framework/Event/ObserverFactory.php(33): Magento\Framework\ObjectManager\ObjectManager->get('VendorName\\Custo...')
#2 /home/user/public_html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(59): Magento\Framework\Event\ObserverFactory->get('VendorName\\Custo...')
#3 /home/user/public_html/vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))
#4 /home/user/public_html/var/generation/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch('customer_sessio...', Array)
#5 /home/user/public_html/vendor/magento/module-customer/Model/Session.php(177): Magento\Framework\Event\Manager\Proxy->dispatch('customer_sessio...', Array)
#6 [internal function]: Magento\Customer\Model\Session->__construct(Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Session\SidResolver\Proxy), Object(Magento\Framework\Session\Config), Object(Magento\Framework\Session\SaveHandler), Object(Magento\Framework\Session\Validator), Object(Magento\Customer\Model\Session\Storage), Object(Magento\Framework\Stdlib\Cookie\PhpCookieManager), Object(Magento\Framework\Stdlib\Cookie\CookieMetadataFactory), Object(Magento\Framework\App\State), Object(Magento\Customer\Model\Config\Share\Proxy), Object(Magento\Framework\Url\Helper\Data), Object(Magento\Customer\Model\Url\Proxy), Object(Magento\Customer\Model\ResourceModel\Customer\Proxy), Object(Magento\Customer\Model\CustomerFactory), Object(Magento\Framework\UrlFactory), Object(Magento\Framework\Session\Generic), Object(Magento\Framework\Event\Manager\Proxy), Object(Magento\Framework\App\Http\Context), Object(Magento\Customer\Api\CustomerRepositoryInterface\Proxy), Object(Magento\Customer\Model\GroupManagement), Object(Magento\Framework\App\Response\Http\Interceptor))
#7 /home/user/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(202): ReflectionClass->newInstanceArgs(Array)
#8 /home/user/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(89): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Custome...', Array)
#9 /home/user/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Custome...')
#10 /home/user/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(236): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Custome...')
#11 /home/user/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Custome...', NULL, 'session', 'VendorName\\Custo...')
#12 /home/user/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('VendorName\\Custo...', Array, Array)
#13 /home/user/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('VendorName\\Custo...')
#14 /home/user/public_html/vendor/magento/framework/Event/ObserverFactory.php(33): Magento\Framework\ObjectManager\ObjectManager->get('VendorName\\Custo...')
#15 /home/user/public_html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(59): Magento\Framework\Event\ObserverFactory->get('VendorName\\Custo...')
#16 /home/user/public_html/vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))
#17 /home/user/public_html/var/generation/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch('customer_sessio...', Array)
#18 /home/user/public_html/vendor/magento/module-customer/Model/Session.php(177): Magento\Framework\Event\Manager\Proxy->dispatch('customer_sessio...', Array)
#19 [internal function]: Magento\Customer\Model\Session->__construct(Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Session\SidResolver\Proxy), Object(Magento\Framework\Session\Config), Object(Magento\Framework\Session\SaveHandler), Object(Magento\Framework\Session\Validator), Object(Magento\Customer\Model\Session\Storage), Object(Magento\Framework\Stdlib\Cookie\PhpCookieManager), Object(Magento\Framework\Stdlib\Cookie\CookieMetadataFactory), Object(Magento\Framework\App\State), Object(Magento\Customer\Model\Config\Share\Proxy), Object(Magento\Framework\Url\Helper\Data), Object(Magento\Customer\Model\Url\Proxy), Object(Magento\Customer\Model\ResourceModel\Customer\Proxy), Object(Magento\Customer\Model\CustomerFactory), Object(Magento\Framework\UrlFactory), Object(Magento\Framework\Session\Generic), Object(Magento\Framework\Event\Manager\Proxy), Object(Magento\Framework\App\Http\Context), Object(Magento\Customer\Api\CustomerRepositoryInterface\Proxy), Object(Magento\Customer\Model\GroupManagement), Object(Magento\Framework\App\Response\Http\Interceptor))
#20 /home/user/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(202): ReflectionClass->newInstanceArgs(Array)
#21 /home/user/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(89): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Custome...', Array)
#22 /home/user/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Custome...')
#23 /home/user/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(236): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Custome...')
#24 /home/user/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Custome...', NULL, 'customerSession', 'Magento\\Weee\\Mo...')
#25 /home/user/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Weee\\Mo...', Array, Array)
#26 /home/user/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Weee\\Mo...')
#27 /home/user/public_html/vendor/magento/framework/Interception/PluginList/PluginList.php(234): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Weee\\Mo...')
#28 /home/user/public_html/vendor/magento/framework/Interception/Interceptor.php(139): Magento\Framework\Interception\PluginList\PluginList->getPlugin('Magento\\Cms\\Con...', 'weee-app-action...')
#29 /home/user/public_html/var/generation/Magento/Cms/Controller/Index/Index/Interceptor.php(39): Magento\Cms\Controller\Index\Index\Interceptor->___callPlugins('dispatch', Array, Array)
#30 /home/user/public_html/vendor/magento/framework/App/FrontController.php(55): Magento\Cms\Controller\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#31 [internal function]: Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#32 /home/user/public_html/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
#33 /home/user/public_html/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#34 /home/user/public_html/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'requestPreproce...')
#35 /home/user/public_html/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(89): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#36 [internal function]: Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#37 /home/user/public_html/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#38 /home/user/public_html/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#39 /home/user/public_html/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#40 [internal function]: Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#41 /home/user/public_html/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#42 /home/user/public_html/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#43 /home/user/public_html/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(68): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#44 [internal function]: Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#45 /home/user/public_html/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#46 /home/user/public_html/vendor/magento/framework/Interception/Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#47 /home/user/public_html/vendor/magento/module-page-cache/Model/App/FrontController/VarnishPlugin.php(55): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#48 [internal function]: Magento\PageCache\Model\App\FrontController\VarnishPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#49 /home/user/public_html/vendor/magento/framework/Interception/Interceptor.php(141): call_user_func_array(Array, Array)
#50 /home/user/public_html/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#51 /home/user/public_html/vendor/magento/framework/App/Http.php(115): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#52 /home/user/public_html/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#53 /home/user/public_html/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#54 {main}
Thank you!
EDIT:
The \Magento\Customer\Model\Session model could not be injected into the observers for the "visitor_init" and "customer_session_init" events.
I am now using "controller_action_predispatch" and can successfully inject the Customer Session Model
Here is my module's etc/frontend/events.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="controller_action_predispatch">
<observer
name="vendorname_controller_action_predispatch"
instance="VendorName\ForceLogin\Observer\ControllerPredispatch" />
</event>
</config>
Sooo .. Turns out the "customer_session" object was available inside the $observer object in my Observer. In my execute() method, I did:
public function execute(Observer $observer) {
$session = $observer->getCustomerSession();
if ($session->isLoggedIn()) {
return;
}
}
In other event hooks such as "controller_action_predispatch", the customer_session object is not available. I found another way to see if a customer is logged in using the HTTP Context object:
/**
* Observer Dependencies
*/
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;
class ControllerPredispatch implements ObserverInterface {
protected $_context;
public function __construct(
\Magento\Framework\App\Http\Context $context
) {
$this->_context = $context;
}
public function execute(Observer $observer) {
$loggedIn = $this->_context->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
if ( $loggedIn ) {
return;
}
}
}

Creating a custom 404 view for Laravel 5

No matter what I do, I can't bind the 404 page to Laravel's handler.
This is what my handler.php looks like:
//app/Exceptions/handler.php
public function render($request, Exception $e)
{
if($this->isHttpException($e))
{
switch ($e->getStatusCode()) {
// not found
case 404:
return \Response::view('errors.404',404);
break;
// internal error
case '500':
return \Response::view('errors.500',500);
break;
default:
return $this->renderHttpException($e);
break;
}
}
else
{
return parent::render($request, $e);
}
}
In my controller I render the view like this:
render view($request)
where $request is the uri.
I added 404.blade.php under /views/errors/, but am still getting Laravel's standard debug error page : Whoops, looks like something went wrong.
dumping $this->isHttpException($e) returns false bolean
Here is the entire log
[2015-06-05 20:41:30] local.ERROR: exception 'InvalidArgumentException' with message 'View [contact] not found.' in /Users/username/Desktop/folderone/folder2/vendor/compiled.php:12898
Stack trace:
#0 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(12871): Illuminate\View\FileViewFinder->findInPaths('contact', Array)
#1 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(12996): Illuminate\View\FileViewFinder->find('contact')
#2 /Users/username/Desktop/folderone/folder2/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(565): Illuminate\View\Factory->make('contact', Array, Array)
#3 /Users/username/Desktop/folderone/folder2/app/Http/Controllers/PageController.php(14): view('contact')
#4 [internal function]: App\Http\Controllers\PageController->show('contact')
#5 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8287): call_user_func_array(Array, Array)
#6 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8354): Illuminate\Routing\Controller->callAction('show', Array)
#7 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8333): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\PageController), Object(Illuminate\Routing\Route), 'show')
#8 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#9 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8952): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#10 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#11 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8935): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#12 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8334): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#13 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8320): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\PageController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'show')
#14 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(7317): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\\Http\\Contro...', 'show')
#15 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(7288): Illuminate\Routing\Route->runWithCustomDispatcher(Object(Illuminate\Http\Request))
#16 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(6954): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#17 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#18 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8952): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#19 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#20 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8935): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#21 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(6955): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#22 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(6944): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#23 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(6929): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#24 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(1935): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#25 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#26 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8952): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#27 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(2438): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#28 /Users/username/Desktop/folderone/folder2/app/Http/Middleware/VerifyCsrfToken.php(17): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#29 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8944): App\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(12083): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#31 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8944): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(10785): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8944): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(11789): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8944): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(11738): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#37 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8944): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(2478): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8944): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#40 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(8935): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#42 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(1891): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#43 /Users/username/Desktop/folderone/folder2/vendor/compiled.php(1880): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#44 /Users/username/Desktop/folderone/folder2/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#45 /Users/username/Desktop/folderone/folder2/server.php(21): require_once('/Users/nashdelo...')
#46 {main}
You do not have to code anything but creating some templates files in views/errors, e.g.
laravel/resources/views/errors/404.blade.php
laravel/resources/views/errors/500.blade.php
laravel/resources/views/errors/403.blade.php
Laravel can render them automatically.
As soon as you want to use Laravel default views/errors directory for storing your custom error views you should call isHttpException() method inside app/Exceptions/handler.php.
/**
* Render an exception into an HTTP response.
*
* #param \Illuminate\Http\Request $request
* #param \Exception $e
* #return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($this->isHttpException($e))
{
switch ($e->getStatusCode()) {
// not found
case 404:
//whatever you want to do with this exception
return $this->renderHttpException($e);
break;
// internal error
case '500':
//whatever you want to do with this exception
return $this->renderHttpException($e);
break;
default:
return $this->renderHttpException($e);
break;
}
}
else
{
return parent::render($request, $e);
}
}

Resources