Laravel To-Do Package


Laravel To-Do package with authentication

GitHub issues GitHub forks GitHub stars


Installation

  • Install package with composer:
    composer require pouya-parsaei/laravel-to-do

  • To authenticate user If User Model has $fillable property, you must add api_token to this array:
    protected $fillable = ['name', 'email', 'password','api_token'];

  • add HasTasks and HasToken traits to User 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 as QUEUE_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 use ResponseHelper Trait and edit render 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