levaral-dev/ core
Levaral基金会包,用于Laravel框架
Requires
- php: ^7.0
- doctrine/common: ^2.9@dev
- doctrine/dbal: ^2.5
- geoip2/geoip2: ~2.0
- gossi/php-code-generator: ^0.5.0
- guzzlehttp/guzzle: ~6.0
- laravel/framework: 5.6.*
This package is not auto-updated.
Last update: 2021-01-30 03:01:02 UTC
README
composer require levaral-dev/core:dev-master
命令
此命令将生成基本结构。
levaral:structure
此命令将生成所有模型的基本类。参数 {model} 将为特定模型生成基本类
levaral:models {model?}
此命令将以纯javascript对象的形式生成所有 [api路由/api服务]
levaral:api-js
此命令将在 Actions 文件夹中生成行为类。
make:action {namespace}
例如
make:action 'User\Profile\GetDetail'
此命令将在 Domain 文件夹中生成模型和基本类。
make:model {namespace}
此命令将扫描 Api 文件夹中的所有 Actions 并生成测试类
levaral:generate-test
此命令将生成 expo token 表和模型。这些令牌将用于发送推送通知。此包还具有 expo 推送通知通道,即 ExpoPushNotification
levaral:user-expo-tokens
此命令将为前端生成语言文件
levaral:generate-language-json
行为路由
行为路由可以在任何 Laravel 路由文件中定义,如 (web.php, api.php 等),使用行为路由时无需定义命名路由,它将自动生成。
例如
Action::get('get-detail', \App\Http\Actions\User\GetDetail::class); // route name User:GetDetail Action::post('get-detail', \App\Http\Actions\User\PostDetail::class); // route name User:PostDetail Action::post('get-detail', \App\Http\Actions\User\PostDetail::class); // route name User:PostDetail Action::post('get-detail', \App\Http\Actions\User\Profile\GetDetail::class); // route name User:Profile:PostDetail
通知通道
邮件通道
Laravel 已经提供了邮件通道,Levaral 邮件通道扩展了 Laravel 邮件通道并提供了更多功能。Levaral 邮件通道将跟踪邮件日志,如已发送、已打开、已点击、失败等。目前 Levaral 邮件通道只支持 Mailgun 和 Sendgrid 的邮件日志。
如何安装
运行以下命令以生成邮件日志表和 MailLog 模型
levaral:maillog:table
要使用 Levaral 邮件通道,请将以下代码添加到 Providers\AppServiceProvider.php 的 register 方法中。这样,现在所有的邮件通知都将使用 Levaral Core MailChannel
$this->app->bind( \Illuminate\Notifications\Channels\MailChannel::class, \Levaral\Core\Channels\MailChannel::class );
注册 MailGun 或 Sendgrid 的 web hook 路由,您需要将这些路由排除在 VerifyCsrfToken 中间件之外
Action::post('/mailgun-webhook', Levaral\Core\Action\MailLog\PostMailGunHook::class); Action::post('/sendgrid-webhook', Levaral\Core\Action\MailLog\PostSendGridHook::class);
ExpoPushNotification
将 toExpo 添加到您的通知类中,例如
function toExpo() { return [ 'body' => 'Test Message' ]; }
如果在上面的数组中包含 to,则通知将只发送到特定设备,如果不包含,则将通知发送到特定可通知对象设备,这些设备在 user_expo_tokens 表中
邮件日志
邮件日志将跟踪您的所有发出的邮件以及发送、打开和点击事件。目前它只支持 Mailgun 和 Sendgrid
运行以下命令以创建邮件日志表
levaral:maillog:table
将行为路由添加到 Laravel 路由文件中。
Action::post('mailgun-webhook', Laravel\Core\Action\MailLog\PostMailGunHook::class); // route for mailgun webhook Action::post('sendgrid-webhook', Laravel\Core\Action\MailLog\PostSendGridHook::class); // route for sendgrid webhook
使用邮件日志历史记录发送邮件通知。
Util::notify($notifiable, $notificationObject, $model)