명령 php artisan make:notification NameOfNotification
은 루멘에 존재하지 않습니다.
해당 패키지를 가져와야합니다.
출처 :이의 필수 의존성 경우 어쩌면
composer require illuminate/notifications
당신이, 내가 100 % 아니에요 require illuminate/support
됩니다 https://stevethomas.com.au/php/using-laravel-notifications-in-lumen.html
는 첫 번째 단계는 켜 집/알림 패키지를 필요로한다 알림. 오류가 발생하면 이것이 원인 일 수 있습니다.
다음, 부트 스트랩에서 서비스 공급자를 등록/app.php
$app->register(\Illuminate\Notifications\NotificationServiceProvider::class);
// optional: register the Facade
$app->withFacades(true, [
'Illuminate\Support\Facades\Notification' => 'Notification',
]);
중 모델 당신이 좋아하는 신고해야할 특성을 추가, 사용자는 명백한 하나가 될 것입니다 :
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
class User extends Model
{
use Notifiable;
}
쓰기 통지를 정상적인 방법 :
<?php
namespace App\Notifications;
use App\Spaceship;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
class SpaceshipHasLaunched extends Notification
{
use Queueable;
/** @var Spaceship */
public $spaceship;
/**
* @param Spaceship $spaceship
*/
public function __construct(Spaceship $spaceship)
{
$this->spaceship = $spaceship;
}
/**
* 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)
->subject('Spacheship has launched!')
->markdown('mail.spaceship', [
'spaceship' => $this->spaceship
]);
}
}
정상적인 방법으로 앱에서 알림을 보냅니다.
$user->notify(new Notifications\SpaceshipHasLaunched($spaceship));
루멘에 해당 기능이 있는지 확실하지 않습니다 ... 루멘은 API 프레임 워크입니다. Laravel에서 버전 5.3 이후에 함수가 있다고 생각합니다. – lewis4u
버전 5.5를 사용 중입니다 – CoolCK
Laravel 또는 Lumen ??? – lewis4u