PHP code example of hpolthof / laravel-api

1. Go to this page and download the library: Download hpolthof/laravel-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hpolthof / laravel-api example snippets

api.errors

public function bindAPI()
{
    return Binding::create([
        'street' => $this->street,
        'street_nr' => $this->number,
        'street_suffix' => $this->suffix,
        'postcode' => $this->zip,
        'city' => $this->city,
    ]);
}

public function index()
{
    $items = Address::all();
    return \Response::api($items);
}
    
public function show($id)
{
    $item = Address::find($id);
    return \Response::api($item);
}