PHP code example of wink / wink-model-generator

1. Go to this page and download the library: Download wink/wink-model-generator 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/ */

    

wink / wink-model-generator example snippets


return [
    // Basic configuration
    'default_connection' => 'mysql',
    'excluded_tables' => ['migrations', 'failed_jobs', /* ... */],

    // Model Property Generation Options
    'model_properties' => [
        // Auto-detect primary key from schema instead of hardcoding 'id'
        'auto_detect_primary_key' => true,

        // Generate $hidden array for sensitive fields (password, token, etc.)
        'auto_hidden_fields' => true,
        'hidden_field_patterns' => ['password', 'token', 'secret', 'key', 'hash'],

        // Generate $guarded array (alternative to $fillable)
        'use_guarded_instead_of_fillable' => false,
        'guarded_fields' => ['id', 'created_at', 'updated_at'],

        // Pagination settings
        'per_page' => null, // Set to integer to override default pagination

        // Date format customization
        'date_format' => 'Y-m-d H:i:s', // Laravel default

        // Auto-generate $attributes for default values based on schema
        'auto_default_attributes' => true,

        // Auto-generate $with for common relationships
        'auto_eager_load' => false,
        'eager_load_relationships' => [], // e.g., ['user', 'category']

        // Soft delete detection
        'auto_detect_soft_deletes' => true,

        // Generate $visible array (alternative to $hidden)
        'use_visible_instead_of_hidden' => false,
    ],

    // Custom field type mappings
    'custom_casts' => [
        // Add custom cast mappings here
    ],

    // Validation rules generation
    'validation' => [
        'generate_rules' => true,
        'strict_rules' => false,
        '
bash
php artisan vendor:publish --provider="Wink\ModelGenerator\ModelGeneratorServiceProvider" --tag="config"