kukuhkkh / laravel-command
Create a Repository and Service class and trait using Artisan CLI
This package is auto-updated.
Last update: 2024-11-08 08:50:31 UTC
README
Laravel More Command
Laravel More Command is a collection of a few php artisan
commands. You can use it to create a Repository, Repository with Interface, Service, Trait, View(blade file), and Clear Log from the command line using php artisan
command.
[Note : This package also worked for nWidart/laravel-modules]
Installation
Require the package with composer using the following command:
composer require kukuhkkh/laravel-command --dev
Or add the following to your composer.json's require-dev section and composer update
"require-dev": { "kukuhkkh/laravel-command": "^1.0.0" }
Artisan Command List
Make Repository
Create a repository Class.
php artisan make:repository your-repository-name
Example:
php artisan make:repository UserRepository
or
php artisan make:repository Backend\UserRepository
The above will create a Repositories directory inside the App directory.\
Create a repository with Interface.
php artisan make:repository your-repository-name -i
Example:
php artisan make:repository UserRepository -i
or
php artisan make:repository Backend\UserRepository -i
Here you need to put extra -i
flag.
The above will create a Repositories directory inside the App directory.
In nWidart/laravel-modules Modules
Create a repository Class.
php artisan module:make-repository your-repository-name {module-name}
Example:
php artisan module:make-repository UserRepository Blog
or
php artisan module:make-repository Backend\UserRepository Blog
The above will create a Repositories directory inside the {Module} directory.
Create a repository with Interface.
php artisan module:make-repository your-repository-name {module-name} -i
Example:
php artisan module:make-repository UserRepository -i Blog
or
php artisan module:make-repository Backend\UserRepository -i Blog
Here you need to put extra -i
flag.
The above will create a Repositories directory inside the {Module} directory.
\
An Example of created repository class:
<?php
namespace App\Repositories;
class UserRepository
{
public function __constuct()
{
//
}
}
Make Service
Create a Service Class.
php artisan make:service your-service-name
Example:
php artisan make:service UserService
or
php artisan make:service Backend\UserService
The above will create a Services directory inside the App directory.
In nWidart/laravel-modules Modules
php artisan module:make-service your-service-name {module-name}
Example:
php artisan module:make-service UserService
or
php artisan module:make-service Backend\UserService
The above will create a Services directory inside the {Module} directory.
Make Trait
Create a Trait.
php artisan make:trait your-trait-name
Example:
php artisan make:trait HasAuth
or
php artisan make:trait Backend\HasAuth
The above will create a Traits directory inside the App directory.
In nWidart/laravel-modules Modules
php artisan module:make-trait your-trait-name {module-name}
Example:
php artisan module:make-trait HasAuth
or
php artisan module:make-trait Backend\HasAuth
The above will create a Traits directory inside the {Module} directory.
Make View
Create a view.
php artisan make:view your-view-file-name
Example:
php artisan make:view index
or
php artisan make:view user\index
The above will create a blade file inside the /resource/views/ directory.
In nWidart/laravel-modules Modules
php artisan module:make-view your-view-file-name {module-name}
Example:
php artisan module:make-view index
or
php artisan module:make-view user\index
The above will create a blade file inside the {Module}/Resources/views/ directory.
Log Clear
php artisan log:clear
The above will deleted all old log data from /storage/logs/ directory.
License
The MIT License (MIT). Please see License for more information.