1. Go to this page and download the library: Download frolaxhq/laravel-typescript 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/ */
frolaxhq / laravel-typescript example snippets
class User extends Model
{
protected $fillable = ['name', 'email'];
protected $hidden = ['password'];
protected $casts = [
'email_verified_at' => 'datetime',
'role' => UserRole::class,
];
public function posts(): HasMany
{
return $this->hasMany(Post::class);
}
}
'discovery' => [
'auto_discover' => true, // Automatically find models in your codebase
'paths' => [app_path('Models')], // Add extra paths if needed
'excluded_models' => ['BaseModel'],
],
'output' => [
'path' => resource_path('types/generated'),
'per_model_files' => true, // One file per model
'barrel_export' => true, // Generate index.ts
'enum_directory' => 'enums', // Subdirectory for enums
],