PHP code example of gaiatools / laravel-type-bridge

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

    

gaiatools / laravel-type-bridge example snippets




namespace App\Enums;

enum Status: string
{
    case Active = 'active';
    case Inactive = 'inactive';
    case Pending = 'pending';
}



namespace App\Enums;

use GaiaTools\TypeBridge\Attributes\GenerateEnum;

#[GenerateEnum]
enum ThemeVisibility: string
{
    case Private = 'private';
    case Unlisted = 'unlisted';
    case Public = 'public';
}



namespace App\Enums;

use GaiaTools\TypeBridge\Attributes\GenerateEnum;

#[GenerateEnum(rt = 'support';
    case Member = 'member';
    case Guest = 'guest';

    /** @return array<int, self> */
    public static function staffRoles(): array
    {
        return [self::Admin, self::Manager, self::Support];
    }

    /** @return array<int, string> */
    public static function memberRoles(): array
    {
        return [self::Member->value, self::Guest->value];
    }
}
bash
php artisan type-bridge:publish
bash
php artisan vendor:publish --tag=type-bridge-config
bash
php artisan type-bridge:enums
bash
php artisan type-bridge:enums --format=js
bash
php artisan type-bridge:enums --check [--format=ts|js]
bash
# Generate translations for a locale (outputs to resources/js/lang/generated)
php artisan type-bridge:translations en

# Generate translations as JSON instead of TS (json|js|ts)
php artisan type-bridge:translations en --format=json

# Generate "flat" translation keys instead of nested
php artisan type-bridge:translations en --flat