PHP code example of stidges / laravel-db-normalizer

1. Go to this page and download the library: Download stidges/laravel-db-normalizer 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/ */

    

stidges / laravel-db-normalizer example snippets


'Stidges\LaravelDbNormalizer\DbNormalizerServiceProvider',

use Stidges\LaravelDbNormalizer\NormalizableModel;

class User extends NormalizableModel
{
    // ...
}

use Stidges\LaravelDbNormalizer\Normalizer;

//...

// Example using the query builder
$result = DB::table('users')->get();
// ... Do stuff with the result.
$normalized = with(new Normalizer)->normalize($result);

// Example using Eloquent
$user = User::find(1);
// ... Do stuff with the user.
$normalized = with(new Normalizer)->normalize($user->toArray());

// Example using Eloquent collection
$users = User::all();
// ... Do stuff with the users.
$normalized = with(new Normalizer)->normalize($users->toArray());