Create A REST API For ToDo App With Authentication Using Lumen

Submitted by azazqadir - 4 months ago

In the first installment of the series on creating a ToDo App with Laravel 5.4, I added an API_KEY column in the user table and commented that I might use it in the future. I will use it in this second installment of the series. In this article, I am going to use the same tables that I created in the ToDo App. I will connect it with Lumen and create a REST API. Source: https://www.cloudways.com/blog/lumen-rest-api-authentication/

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

use Illuminate\Contracts\Auth\Authenticatable;

use Illuminate\Auth\Authenticatable as AuthenticableTrait;


class Users extends Model implements Authenticatable

{

   //

   use AuthenticableTrait;

   protected $fillable = ['username','email','password','userimage'];

   protected $hidden = [

   'password'

   ];

   /*

   * Get Todo of User

   *

   */

   public function todo()

   {

       return $this->hasMany('App\Todo','user_id');

   }

}

Ads cover the costs of maintaining Laravel-tricks

comments powered by Disqus

Ads cover the costs of maintaining Laravel-tricks