Skip to content

Commit

Permalink
Merge pull request #9 from xuandung38/master
Browse files Browse the repository at this point in the history
Fix issues when creating New modules title_case and str_plural
  • Loading branch information
bvipul authored Nov 22, 2019
2 parents 10df87f + ca05ac6 commit 3acbcf4
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 73 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ and you can get the title "Module Management" from package's translation file by
You can contribute to this project, by just taking fork of it. We are open for suggestion and PRs. If you have any new suggestions or anything for that matter, contact me at [email protected]



# Note
This is hotfix for `https://github.com/viralsolani/laravel-adminpanel/issues/528`
17 changes: 7 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
"description": "To create a whole module with all related files like model, controller, repository, routes, views etc with a simple GUI.",
"type": "package",
"license": "MIT",
"authors": [
{
"name": "Vipul Basapati",
"email": "[email protected]"
}
],
"authors": [{
"name": "Vipul Basapati",
"email": "[email protected]"
}],
"autoload": {
"psr-4": {
"psr-4": {
"Bvipul\\Generator\\": "src/"
}
},
"require": {
}
}
"require": {}
}
9 changes: 5 additions & 4 deletions src/Controllers/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public function getRepoNamespace()
public function getResponsesNamespace()
{
return $this->responses_namespace;
}
}

/**
* @return string
Expand Down Expand Up @@ -586,7 +586,7 @@ public function createResponses()
// 'DummyClass' => $this->store_request,
// 'permission' => $this->store_permission,
// ], lcfirst($this->store_request_namespace));
// }
// }
}

/**
Expand Down Expand Up @@ -967,10 +967,11 @@ public function getStubPath()
{
$path = resource_path('views'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'generator'.DIRECTORY_SEPARATOR.'Stubs'.DIRECTORY_SEPARATOR);
$package_stubs_path = base_path('vendor'.DIRECTORY_SEPARATOR.'bvipul'.DIRECTORY_SEPARATOR.'generator'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.'Stubs'.DIRECTORY_SEPARATOR);
if($this->files->exists($path))
if ($this->files->exists($path)) {
return $path;
else
} else {
return $package_stubs_path;
}
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Repositories/ModuleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Exceptions\GeneralException;
use App\Repositories\BaseRepository;
use App\Models\Access\Permission\Permission;
use Illuminate\Support\Str;

/**
* Class ModuleRepository.
Expand Down Expand Up @@ -53,7 +54,7 @@ public function create(array $input, array $permissions)
foreach ($permissions as $permission) {
$perm = [
'name' => $permission,
'display_name' => title_case(str_replace('-', ' ', $permission)).' Permission',
'display_name' => Str::title(str_replace('-', ' ', $permission)).' Permission',
];
//Creating Permission
$per = Permission::firstOrCreate($perm);
Expand All @@ -62,15 +63,14 @@ public function create(array $input, array $permissions)
$mod = [
'view_permission_id' => "view-$model-permission",
'name' => $input['name'],
'url' => 'admin.'.str_plural($model).'.index',
'url' => 'admin.'.Str::plural($model).'.index',
'created_by' => access()->user()->id,
];

$create = Module::create($mod);

return $create;
}
else {
} else {
return $module;
}

Expand Down
2 changes: 1 addition & 1 deletion src/config/generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
// Default : backend
'views_folder' => 'backend',

];
];
2 changes: 1 addition & 1 deletion src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ function get_array_contents($arr)

return $contents;
}
}
}
70 changes: 35 additions & 35 deletions src/lang/en/labels.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
<?php

return [
"modules" => [
"create" => "Create Module",
"management" => "Module Management",
"title" => "Module",
"edit" => "Edit Module",
"table" => [
"name" => "Module Name",
"url" => "Module View Route",
"view_permission_id" => "View Permission",
"created_by" => "Created By",
],
"form" => [
"name" => "Module Name",
"url" => "View Route",
"view_permission_id" => "View Permission",
"directory_name" => "Directory Name",
"namespace" => "Namespace",
"model_name" => "Model Name",
"controller_name" => "Controller &nbsp;Name",
"resource_controller" => "Resourceful Controller",
"table_controller_name" => "Controller &nbsp;Name",
"table_name" => "Table Name",
"route_name" => "Route Name",
"route_controller_name" => "Controller &nbsp;Name",
"resource_route" => "Resourceful Routes",
"views_directory" => "Directory &nbsp;&nbsp;&nbsp;Name",
"index_file" => "Index",
"create_file" => "Create",
"edit_file" => "Edit",
"form_file" => "Form",
"repo_name" => "Repository Name",
"event" => "Event Name",
],
]
];
"modules" => [
"create" => "Create Module",
"management" => "Module Management",
"title" => "Module",
"edit" => "Edit Module",
"table" => [
"name" => "Module Name",
"url" => "Module View Route",
"view_permission_id" => "View Permission",
"created_by" => "Created By",
],
"form" => [
"name" => "Module Name",
"url" => "View Route",
"view_permission_id" => "View Permission",
"directory_name" => "Directory Name",
"namespace" => "Namespace",
"model_name" => "Model Name",
"controller_name" => "Controller &nbsp;Name",
"resource_controller" => "Resourceful Controller",
"table_controller_name" => "Controller &nbsp;Name",
"table_name" => "Table Name",
"route_name" => "Route Name",
"route_controller_name" => "Controller &nbsp;Name",
"resource_route" => "Resourceful Routes",
"views_directory" => "Directory &nbsp;&nbsp;&nbsp;Name",
"index_file" => "Index",
"create_file" => "Create",
"edit_file" => "Edit",
"form_file" => "Form",
"repo_name" => "Repository Name",
"event" => "Event Name",
],
]
];
14 changes: 7 additions & 7 deletions src/lang/en/menus.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

return [
"modules" => [
"all" => "All Modules Page",
"create" => "Create Module Page",
"management" => "Module Management",
"main" => "Module Pages",
]
];
"modules" => [
"all" => "All Modules Page",
"create" => "Create Module Page",
"management" => "Module Management",
"main" => "Module Pages",
]
];
4 changes: 2 additions & 2 deletions src/routes.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

Route::group(['namespace' => 'Bvipul\Generator\Controllers', 'prefix' => 'admin', 'as' => 'admin.', 'middleware' => ['web', 'admin'] ], function () {
Route::resource('modules', 'ModuleController');
Route::resource('modules', 'ModuleController');

//For DataTables
Route::post('modules/get', 'ModuleTableController')
Expand All @@ -12,4 +12,4 @@
Route::post('modules/checkTable', 'ModuleController@checkTable')->name('modules.check.table');
//checking permission exists
Route::post('modules/checkPermission', 'ModuleController@checkPermission')->name('modules.check.permission');
});
});
7 changes: 3 additions & 4 deletions src/views/Stubs/Attribute.stub
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace AttributeNamespace;
trait AttributeClass
{
// Make your attributes functions here
// Further, see the documentation : https://laravel.com/docs/5.4/eloquent-mutators#defining-an-accessor
// Further, see the documentation : https://laravel.com/docs/6.x/eloquent-mutators#defining-an-accessor


/**
Expand All @@ -17,9 +17,8 @@ trait AttributeClass
*/
public function getActionButtonsAttribute()
{
return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute("editPermission", "editRoute").'
'.$this->getDeleteButtonAttribute("deletePermission", "deleteRoute").'
return '<div class="btn-group action-btn"> {$this->getEditButtonAttribute("editPermission", "editRoute")}
{$this->getDeleteButtonAttribute("deletePermission", "deleteRoute")}
</div>';
}
}
2 changes: 1 addition & 1 deletion src/views/Stubs/Model.stub
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DummyModel extends Model

/**
* NOTE : If you want to implement Soft Deletes in this model,
* then follow the steps here : https://laravel.com/docs/5.4/eloquent#soft-deleting
* then follow the steps here : https://laravel.com/docs/6.x/eloquent#soft-deleting
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion src/views/Stubs/Relationship.stub
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ trait RelationshipClass
public function users() {
//Note that the below will only work if user is represented as user_id in your table
//otherwise you have to provide the column name as a parameter
//see the documentation here : https://laravel.com/docs/5.4/eloquent-relationships
//see the documentation here : https://laravel.com/docs/6.x/eloquent-relationships
$this->belongsTo(User::class);
}
*/
Expand Down
4 changes: 2 additions & 2 deletions src/views/Stubs/Request.stub
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DummyClass extends FormRequest
return [
//Put your rules for the request in here
//For Example : 'title' => 'required'
//Further, see the documentation : https://laravel.com/docs/5.4/validation#creating-form-requests
//Further, see the documentation : https://laravel.com/docs/6.x/validation#creating-form-requests
];
}

Expand All @@ -35,7 +35,7 @@ class DummyClass extends FormRequest
return [
//The Custom messages would go in here
//For Example : 'title.required' => 'You need to fill in the title field.'
//Further, see the documentation : https://laravel.com/docs/5.4/validation#customizing-the-error-messages
//Further, see the documentation : https://laravel.com/docs/6.x/validation#customizing-the-error-messages
];
}
}

0 comments on commit 3acbcf4

Please sign in to comment.