tur1/laravelmodules is a Laravel package for a laravel package for creating modules and pages.
It currently has 0 GitHub stars and 43 downloads on Packagist (latest version v1.4.0).
Install it with composer require tur1/laravelmodules.
Discover more Laravel packages by tur1
or browse all Laravel packages to compare alternatives.
Last updated
tur1/laravel-modules is a Laravel package which was created to manage your large Laravel app using modules.
This package provides a set of Artisan commands and tools to easily create modules, pages, and filters in your Laravel application.
Generate your first module using php artisan module:create Admins. The following structure will be generated.
Modules/
├── Admins/
├── Controllers/
│ └── AdminController.php
├── Database/
│ ├── factories/
│ │ └── AdminFactory.php
│ ├── migrations/
│ │ └── 2024_09_16_xxxxxxx_admins_table.php
│ └── seeders/
│ └── AdminSeeder.php
├── Events/
│ ├── AdminCreatedEvent.php
│ ├── AdminDeletedEvent.php
│ └── AdminUpdatedEvent.php
├── Exceptions/
│ └── AdminException.php
├── Filters/
│ ├── GenderFilter.php
│ └── StatusFilter.php
├── Middleware/
│ └── AdminMiddleware.php
├── Models/
│ └── Admin.php
├── Observers/
│ └── AdminObserver.php
├── Policies/
│ └── AdminPolicy.php
├── Requests/
│ ├── StoreAdminRequest.php
│ └── UpdateAdminRequest.php
├── Resources/
│ ├── AdminListResource.php
│ └── AdminShowResource.php
├── Routes/
│ └── AdminRoutes.php
├── Services/
│ └── AdminService.php
└── Traits/
├── AdminAttributesTrait.php
├── AdminRelationshipsTrait.php
└── AdminScopesTrait.php
To install the package, run:
composer require tur1/modules
To create a new module, use the following command:
php artisan module:create Users
This will generate a Users module in the app/Modules directory.
To create a new page within a module, use:
php artisan page:create Dashboard
This will generate a Dashboard page
To create a new filter within a module, use:
php artisan module:filter {name} --m={module-name}
Example:
php artisan module:filter StatusFilter --m=Users
This will create a StatusFilter class in the app/Modules/Users/Filters directory.
You can register filters for a model by defining a filters() method in your model. For example:
class User extends Model
{
/**
* Register filters for the User model.
*
* @return array
*/
public static function filters()
{
return [
StatusFilter::class,
];
}
}
To apply filters to a query, use the withFilters() method:
User::withFilters()->get();
Define a $search property in your model to enable search functionality. Use an array of field names, including related fields with dot notation (e.g., roles.name).
Example:
class User extends Model
{
protected $search = ['name', 'email', 'roles.name'];
public function roles()
{
return $this->hasMany(Role::class);
}
/**
* Register filters for the User model.
*
* @return array
*/
public static function filters()
{
return [
StatusFilter::class,
];
}
}