get data with API

 How to get data with API.?

1. Step Go Terminal

php artisan make:migration create_abc_table    Press Enter

Create Table


2. Step  go Terminal

 php artisan migrate

3. Step 

Check Database

4. Step
Let's start get data with API
Create the Controller

go Terminal

php artisan make:controller  DBController

    // Get data with API form DB
 function list()
    {
        return ClientModel::all();
    }

5. Step
Create the Model

go Terminal

php artisan make:model  ClientModel

class ClientModel extends Model
{
    use HasFactory;

    protected $table = 'clientmodel';
    protected $fillable = ['name', 'email', 'address'];
}

6. Step
go routes and create the route

Route::get("lists", [DBController::class, 'list']);

Output:



Comments

Popular posts from this blog

Get API with Parameter