【发布时间】:2017-06-08 07:07:13
【问题描述】:
我有一个控制器,它监听新的调度创建并通过 ajax 将结果发送回视图。在其中我想添加一个通知,以便在由于特定日期和时间缺乏资源而无法完成计划时向用户发送电子邮件。
问题是我收到以下错误:
Class 'App\Http\Controllers\Notification' not found in /laravel/app/Http/Controllers/DadosAgendamentoController.php on line 89
文件夹结构是这样的:
-app
-Http
-Controllers
DadosAgendamentoController.php
-Notifications
AgendamentoPendente.php
DadosAgenmentoController.php 头部代码:
namespace App\Http\Controllers;
use Input;
use Request;
use App\Servicos;
use App\Disponibilidades;
use App\Estabelecimentos;
use App\HorariosEstabelecimento;
use App\Agendamento;
use App\User;
use App\Notifications\AgendamentoPendente;
第 88 和 89 行:
$user = User::where('id',1)->get();
Notification::send($user, new AgendamentoPendente(1));
通过我的控制器,我可以访问上述所有类,但不能访问 AgenmentoPendente
我的目标是向管理员发送一封电子邮件,以便当资源在所需的日期和时间不可用时,他可以向客户建议一个新的日期和时间。
如何解决?我可以访问此控制器中的类吗?怎么样?
【问题讨论】:
-
请告诉我们
89th line of DadosAgendamentoController.php -
我几乎可以肯定你还没有导入
Notification类。只需导入命名空间,它应该是固定的。如果 Notification 是一个门面,只需通过\Notification::foo()调用 -
@AlexeyMezenin,我已经编辑了问题。
-
@felipsmartins,我看到用户有一个使用通知的默认配置,我也尝试使用命令
use Illuminate\Notifications\Notifiable;,但没有成功 -
@JaquelinePassos Alexey Mezenin 的回答是正确的。即使它不能解决您的问题,但在另一个地方/范围内存在问题。
标签: php laravel laravel-5 facade