powya-parsaei / laravel-to-do
带有认证功能的 Laravel To-Do 包
dev-master
2022-05-27 16:57 UTC
This package is auto-updated.
Last update: 2024-09-27 22:24:49 UTC
README
带有认证功能的 Laravel To-Do 包
安装
- 使用 composer 安装包
composer require powya-parsaei/laravel-to-do - 如果
User模型有$fillable属性,你必须将api_token添加到这个数组中
protected $fillable = ['name', 'email', 'password','api_token']; - 将
HasTasks和HasToken特性添加到User模型
<?php
namespace App;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use PouyaParsaei\LaravelToDo\Traits\HasTasks;
use PouyaParsaei\LaravelToDo\Traits\HasToken;
class User extends Authenticatable
{
use Notifiable, HasTasks, HasToken;
}
- 在
.env文件中设置你的MAIL配置 - 在
.env文件中设置你的QUEUE_CONNECTION配置 #### 注意 - 如果你想要使用
database作为QUEUE_CONNECTION并且数据库中还没有工作表,请创建它
php artisan queue:table - 如果你数据库中还没有
notifications表,请创建它
php artisan notification:table - 在
app/Exceptions/Handler.php文件中使用ResponseHelper特性并修改render函数如下
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use PouyaParsaei\LaravelToDo\Helpers\ResponseHelper;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Illuminate\Database\Eloquent\ModelNotFoundException as IlluminateModelNotFoundException;
use Throwable;
class Handler extends ExceptionHandler
{
use ResponseHelper;
public function render($request, Throwable $exception)
{
if (($exception instanceof NotFoundHttpException || $exception instanceof IlluminateModelNotFoundException) && $request->wantsJson()) {
return $this->respondNotFound(trans('todo::messages.errors.not found'));
}
return parent::render($request, $exception);
}
}
- 运行迁移
php artisan migrate - 启动工作进程
php artisan queue:work