PHP code example of vicenterusso / laravel-table-structure

1. Go to this page and download the library: Download vicenterusso/laravel-table-structure 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/ */

    

vicenterusso / laravel-table-structure example snippets


return [

    /*
    |--------------------------------------------------------------------------
    | Enable Cache
    |--------------------------------------------------------------------------
    |
    | Enable or disable usage of cache for Schema queries.
    |
    */
    'use_cache' => false,

    /*
    |--------------------------------------------------------------------------
    | Cache Prefix
    |--------------------------------------------------------------------------
    |
    | Custom prefix for cache keys. Avoid empty values
    |
    */
    'cache_prefix' => env('TABLE_STRUCT_PREFIX', 'TABLE_STRUCT'),

];

# Add trait to model
use \VRusso\TableStructure\Traits\FieldsInfo;

# Call it anywhere
User::hasField('username'); 
//true/false

User::getAllFields();
//['username', 'password', ...]

User::getAllFieldsWithTypes();
//[
//    [
//    'field' => 'username',
//    'type' => 'string'
//    ],
//    (...)
//]

User::getAllFieldsWithTypeOf('integer');
//['id', ...]
bash
php artisan vendor:publish --provider="VRusso\TableStructure\TableStructureServiceProvider" --tag="laravel_table_structure-config"