ahmed-aliraqi/crud-generator
| Install | |
|---|---|
composer require ahmed-aliraqi/crud-generator |
|
| Latest Version: | v7.0.1 |
| PHP: | >=8.2 |
| License: | MIT |
| Last Updated: | May 9, 2026 |
| Links: | GitHub · Packagist |
CRUD. Generator
Introduction
This package is a useful tool to generate simple crud for laravel-modules/scaffolding
the files that will be generated is:
- Lang Files (ar & en)
- Breadcrumb File
- View Files
- Api Resource Files
- Migration Files
- Factory File
- Policy Files
- Controller Files
- Model Files
- Request Files
- Filter Files
- Test Files
Installation
composer require ahmed-aliraqi/crud-generator --dev
Configuration
You should add config file using the following command to configure the supported resources.
php artisan vendor:publish --provider="AhmedAliraqi\CrudGenerator\CrudServiceProvider"
Then add the following comment line in the routes/dashboard.php and routes/api.php files:
/* The routes of generated crud will set here: Don't remove this line */
And the follwing comment line in the resources/views/layouts/sidebar.blade.php file:
{{-- The sidebar of generated crud will set here: Don't remove this line --}}
Usage
For example if you want to generate a new CRUD named category. make sure it's arabic words was defined in arabicWords of config file and then use the following artisan command:
php artisan make:crud category
Use translatable option if the CRUD is translatable:
php artisan make:crud category --translatable
Use has-media option if the CRUD has media:
php artisan make:crud category --has-media
Also you can use both options together to generate translatable and has media CRUD.
php artisan make:crud category --translatable --has-media
Account Type Cloner
php artisan account:clone customer merchant
This command will clone
customeraccount type to another type namedmerchant,
Some files should be modified manually like:
- add constant for the newly generated type in
app/Models/User.php
/**
* The code of merchant type.
*
* @var string
*/
const MERCHANT_TYPE = 'merchant';
Then register the type in childTypes array:
/**
* @var array
*/
protected $childTypes = [
// other types ...
self::MERCHANT_TYPE => Merchant::class,
];
- Add check for type helper in
app/Models/Helpers/UserHelper.php:
/**
* Determine whether the user type is merchant.
*
* @return bool
*/
public function isMerchant()
{
return $this->type == User::MERCHANT_TYPE;
}
- Add seeders in
database/seeders/UserSeeder.php:
Merchant::factory()->count(10)->create();
- Add translation lang file name to
config/lang-generator.php
'lang' => [
// ...
'merchants' => base_path('lang/{lang}/merchants.php'),
/* The lang of generated crud will set here: Don't remove this line */
],
- Update arabic translations in lang file for generated type
lang/ar/merchants.php - Add type translated key into
lang/{lang}/users.php:
'types' => [
// Other types ...
'merchant' => 'Merchant',
],
- Clone view files in dashboard from
customerdirectory tomerchantand replace allcustomerword tomerchantCustomer=>Merchantcustomers=>merchantscustomer=>merchant
- Add Sidebar link in
resources/views/dashboard/accounts/sidebar.blade.php:
[
'name' => trans('merchants.plural'),
'url' => route('dashboard.merchants.index'),
'can' => ['ability' => 'viewAny', 'model' => \App\Models\Merchant::class],
'active' => request()->routeIs('*merchants*'),
],
- Add the routes for the newly generated type in
routes/dashboard.phpfile:
// Merchants Routes.
Route::get('trashed/merchants', 'MerchantController@trashed')->name('merchants.trashed');
Route::get('trashed/merchants/{trashed_merchant}', 'MerchantController@showTrashed')->name('merchants.trashed.show');
Route::post('merchants/{trashed_merchant}/restore', 'MerchantController@restore')->name('merchants.restore');
Route::delete('merchants/{trashed_merchant}/forceDelete', 'MerchantController@forceDelete')->name('merchants.forceDelete');
Route::resource('merchants', 'MerchantController');
- Add route binding in
storage/soft_deletes_route_binding.json:
{
"trashed_merchant": "App\\Models\\Merchant"
}
- Add the permision in
storage/permissions.json:
[
"manage.merchants"
]
- Add
actingAsMerchanthelper intotests/TestCase.php
/**
* Set the currently logged in merchant for the application.
*
* @param null $driver
* @return \App\Models\Merchant
*/
public function actingAsMerchant($driver = null)
{
$merchant = Merchant::factory()->create();
$this->be($merchant, $driver);
return $merchant;
}
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v7.0.1 | >=8.2 | >=9.0 | MIT | |
| v7.0.0 | >=8.2 | >=9.0 | MIT | |
| v6.2.0 | >=8.2 | >=9.0 | MIT | |
| v6.1.0 | >=8.2 | >=9.0 | MIT | |
| v6.0.2 | >=8.2 | >=9.0 | MIT | |
| v6.0.1 | >=8.2 | >=9.0 | MIT | |
| v6.0.0 | >=8.2 | >=9.0 | MIT | |
| v5.0.2 | >=8.0 | >=9.0 | MIT | |
| v5.0.1 | >=8.0 | >=9.0 | MIT | |
| v5.0.0 | >=8.0 | >=9.0 | MIT | |
| v4.1.0 | >=8.0 | >=9.0 | MIT | |
| v4.0.3 | ^8.0.2 | ^9.0 | MIT | |
| v4.0.2 | ^8.0.2 | ^9.0 | MIT | |
| v4.0.1 | ^8.0.2 | ^9.0 | MIT | |
| v4.0.0 | ^8.0.2 | ^9.0 | MIT | |
| v3.3.0 | ^7.4| | ^6.0| | MIT | |
| v3.2.3 | ^7.4| | ^6.0| | MIT | |
| v3.2.2 | ^7.4 | ^6.0| | MIT | |
| v3.2.1 | ^7.4 | ^6.0| | MIT | |
| v3.2.0 | ^7.4 | ^6.0| | MIT | |
| v3.1.0 | ^7.4 | ^6.0| | MIT | |
| v3.0.1 | ^7.4 | ^6.0| | MIT | |
| v3.0.0 | ^7.4 | ^6.0| | MIT | |
| v2.0.0 | ^7.4 | ^6.0| | MIT | |
| v1.0.1 | ^7.4 | ^6.0| | MIT | |
| v1.0.0 | ^7.4 | ^6.0| | MIT |