Skip to content

oguzcandemircan/laravel-stub-generator

Repository files navigation

Laravel Stub Generator

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.

About

No description, website, or topics provided.

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
license.md

Stars

Watchers

Forks

Packages

No packages published

Languages