コマンド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