PHP code example of jdiassdev / laravel-types-gen

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

    

jdiassdev / laravel-types-gen example snippets


public function rules(): array
{
    return [
        'name'  => '|integer|nullable',
        'bio'   => 'string',
    ];
}

public function rules(): array
{
    return [
        'name'  => ['

public function rules(): array
{
    return [
        'address.city'   => 'd|string',
        'items.*.qty'    => '

public function toArray(Request $request): array
{
    return [
        'id'         => $this->id,
        'name'       => $this->name,
        'email'      => $this->email,
        'created_at' => $this->created_at,
    ];
}

// config/laravel-types-gen.php

return [
    /*
    |--------------------------------------------------------------------------
    | Output Path
    |--------------------------------------------------------------------------
    |
    | The directory where the generated TypeScript files will be written.
    | Both api-request.ts and api-resource.ts are placed inside this path.
    |
    */
    'output_path' => resource_path('types'),
];
bash
php artisan ts:generate
bash
php artisan ts:generate