我已经在我的应用程序上实现了通知。他们工作正常,直到昨天突然停止工作。现在,当我点击启用通知的路线时,它只是继续加载这是存储方法我的控制器,我检查是否启用了电子邮件通知,如果是用户,则应在每次发布项目时收到电子邮件
public function store(Request $request){
$this->validate(request(), [
'title' => 'required|max:255|unique:projects',
'body' => 'required|max:1000',
// 'tutorial' => 'required|max:1000',
'avatar' => 'required|mimes:jpeg,bmp,png',
'zip_file' => 'required|mimes:zip,rar',
]);
$user = User::all();
$profiles_storage = storage_path('app/avatars/');
$project = new Project;
$project -> user_id = auth()->id();
$project -> title = request('title');
$project -> body = request('body');
$project -> tutorial = request('tutorial');
$project -> views = '0';
$project -> downloads = '0';
$project -> alternative_text = config('app.name').' '.request('title').' '.'project';
$profile = request()->file('avatar');
// $profile->store('profiles');
$project->image = $profile->hashName();
$image = Image::make($profile->getRealPath());
$image->fit(640, 360, function ($constraint)
{ $constraint->upsize();})->save($profiles_storage.$profile->hashName());
request()-> file('zip_file')->store('zip_files');
$project -> zip_file = request()->file('zip_file')->hashName();
$project -> save();
$category = $request->input('categories');
$project->categories()->sync($category);
foreach ($user as $u) {
if ($u->email_notifications != 0) {
$u->notify(new ProjectPublished($project));
}
}
session()->flash('message',"{$project->title}".' created');
return redirect('/admin/projects');
}
这是ProjectPublished.php
<?php
namespace App\Notifications;
use App\User; use App\Project; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage;
class ProjectPublished extends Notification { use Queueable; protected $project;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(Project $project)
{
$this->project = $project;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->greeting('Hello there')
->subject('New Project:'.$this->project->title)
->line('As requested we are letting you know that a new project was published at Rek Studio')
->action('Check it out', url('projects/'.$this->project->title));
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
任何人都可以帮助我吗?