pouya-parsaei / laravel-to-do
Laravel To-Do package with authentication
dev-master
2022-05-27 16:57 UTC
This package is auto-updated.
Last update: 2025-05-27 23:41:50 UTC
README
Laravel To-Do package with authentication
Installation
- Install package with composer:
composer require pouya-parsaei/laravel-to-do
- To authenticate user If
User
Model has$fillable
property, you must addapi_token
to this array:
protected $fillable = ['name', 'email', 'password','api_token'];
- add
HasTasks
andHasToken
traits toUser
Model:
<?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;
}
- set your
MAIL
settings in.env
file - set your
QUEUE_CONNECTION
in.env
file ####note: - If you want to use
database
asQUEUE_CONNECTION
and already don’t have jobs table in database, create it:
php artisan queue:table
- If you already do not have
notifications
table in the database, create it:
php artisan notification:table
- In
app/Exceptions/Handler.php
useResponseHelper
Trait and editrender
function like this:
<?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);
}
}
- run migrate:
php artisan migrate
- start worker:
php artisan queue:work