PHP code example of bauerdot / laravel-dbml

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

    

bauerdot / laravel-dbml example snippets


/**
 * @json-structure {
 *   "name": "string",
 *   "address": {
 *     "street": "string",
 *     "city": "string"
 *   }
 * }
 */
protected $casts = [
    'settings' => 'json',
];

class Broker extends Model
{
    protected $casts = [
        'permanent_address' => AddressValueObject::class,
        'contact_address' => AddressValueObject::class
    ];
}

class AddressValueObject extends Data
{
    public function __construct(
        public readonly ?string $city,
        public readonly ?string $street,
        public readonly ?string $country,
        public readonly ?string $zip,
        public readonly ?string $houseNumber,
        public readonly ?string $district = null,
        public readonly ?string $referenceNumber = null
    ) {}
}
bash
php artisan dbml:parse --
bash
php artisan dbml:parse --no-ignore
bash
php artisan vendor:publish --provider="Bauerdot\\LaravelDbml\\LaravelDbmlServiceProvider" --tag="config"
bash
# Parse only the 'users' and 'posts' tables
php artisan dbml:parse --only=users,posts

# Parse tables that match a pattern
php artisan dbml:parse --only="user_*"

# You can also specify multiple --only options
php artisan dbml:parse --only=users --only=posts