oguzcandemircan/laravel-stub-generator

v0.1.1 2021-07-10 03:32 UTC

This package is not auto-updated.

Last update: 2024-10-26 20:41:34 UTC


README

Latest Version on Packagist Total Downloads

This is where your description should go. Take a look at contributing.md to see a to do list.

Installation

Via Composer

$ composer require oguzcandemircan/laravel-stub-generator

Config

return [
    'source_path' => storage_path('stubs/source'), // stubs source path
    'target_path' => storage_path('stubs/target'), // stubs target path
];

Usage

Stub file:

//storage/stubs/source/model.stub

namespace {{namespace}};

use Illuminate\Database\Eloquent\Model;

class {{modelName}} extends Model
{
    protected $fillable = [{{fillable}}];
}

Generate:

LaravelStubGenerator::source('model')->params([
  '{{modelName}}' => 'UserModel',
  '{{namespace}}' => 'App\Models',
  '{{fillable}}' => "'name', 'email', 'age'",
])->generate();

Save:

LaravelStubGenerator::source('model')->params([
  '{{modelName}}' => 'UserModel',
  '{{namespace}}' => 'App\Models',
  '{{fillable}}' => "'name', 'email', 'age'",
])->save('UserModel.php');

// force save
->save('UserModel.php', true);

Output:

//storage/stubs/target/UserModel.php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class UserModel extends Model
{
    protected $fillable = ['name', 'email', 'age'];
}

Download:

LaravelStubGenerator::source('model')->params([
  '{{modelName}}' => 'UserModel',
  '{{namespace}}' => 'App\Models',
  '{{fillable}}' => "'name', 'email', 'age'",
])->download('UserModel.php');

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.