Unverified Commit 4d4cf751 authored by Viral Solani's avatar Viral Solani Committed by GitHub

Merge pull request #26 from bvipul/vs_module_package_create

Removed Module and Menu Management and added Module Package
parents ac405436 bff563db
<?php
/**
* Routes for : DummyModuleName
*/
@startNamespace
Route::group( ['namespace' => 'DummyModel'], function () {
Route::get('dummy_name', 'DummyController@index')->name('dummy_name.index');
@startCreateRoute::get('dummy_name/create', 'DummyController@create')->name('dummy_name.create');
Route::post('dummy_name', 'DummyController@store')->name('dummy_name.store');@endCreate
@startEditRoute::get('dummy_name/{dummy_argument_name}/edit', 'DummyController@edit')->name('dummy_name.edit');
Route::patch('dummy_name/{dummy_argument_name}', 'DummyController@update')->name('dummy_name.update');@endEdit
@startDeleteRoute::delete('dummy_name/{dummy_argument_name}', 'DummyController@destroy')->name('dummy_name.destroy');@endDelete
//For Datatable
Route::post('dummy_name/get', 'DummyTableController')->name('dummy_name.get');
});
@endNamespace@startWithoutNamespace
Route::get('dummy_name', 'DummyController@index')->name('dummy_name.index');
@startCreateRoute::get('dummy_name/create', 'DummyController@create')->name('dummy_name.create');
Route::post('dummy_name', 'DummyController@store')->name('dummy_name.store');@endCreate
@startEditRoute::get('dummy_name/{dummy_argument_name}/edit', 'DummyController@edit')->name('dummy_name.edit');
Route::patch('dummy_name/{dummy_argument_name}', 'DummyController@update')->name('dummy_name.update');@endEdit
@startDeleteRoute::delete('dummy_name/{dummy_argument_name}', 'DummyController@destroy')->name('dummy_name.destroy');@endDelete
//For Datatable
Route::post('dummy_name/get', 'DummyTableController')->name('dummy_name.get');
@endWithoutNamespace
......@@ -175,64 +175,6 @@ if (!function_exists('escapeSlashes')) {
}
}
if (!function_exists('get_array_contents')) {
function get_array_contents($arr)
{
$contents = '';
foreach ($arr as $key => $value) {
if (is_array($value)) {
$contents .= "\t\"$key\" => [\n";
$contents .= get_array_contents($value);
$contents .= "\t],\n";
} else {
$contents .= "\t\"$key\" => \"$value\",\n";
}
}
return $contents;
}
}
if (!function_exists('insert_into_array')) {
function insert_into_array(&$array, array $keys, $value)
{
$last = array_pop($keys);
foreach ($keys as $key) {
if (!array_key_exists($key, $array) ||
array_key_exists($key, $array) && !is_array($array[$key])) {
$array[$key] = [];
}
$array = &$array[$key];
}
if (is_array($array[$last])) {
$array[$last] = array_merge($array[$last], $value);
} else {
$array[$last] = $value;
}
}
}
if (!function_exists('add_key_value_in_file')) {
function add_key_value_in_file($file_name, $new_key_value, $parent_keys = null)
{
$file_array = eval(str_replace('<?php', '', str_replace('?>', '', file_get_contents($file_name))));
if (!empty($parent_keys)) {
$parents = explode('.', $parent_keys);
insert_into_array($file_array, $parents, $new_key_value);
} else {
foreach ($new_key_value as $key => $value) {
$file_array[$key] = $value;
}
}
// dd($file_array);
$file_contents_new = "<?php\nreturn [\n";
$file_contents_new .= get_array_contents($file_array);
$file_contents_new .= '];';
// dd($file_contents_new);
file_put_contents($file_name, $file_contents_new);
}
}
if (!function_exists('getMenuItems')) {
/**
* Converts items (json string) to array and return array.
......
......@@ -15,6 +15,4 @@ require __DIR__.'/Blog_Category.php';
require __DIR__.'/Blog_Tag.php';
require __DIR__.'/Blog_Management.php';
require __DIR__.'/Faqs.php';
require __DIR__.'/Module.php';
require __DIR__.'/Menu.php';
require __DIR__.'/LogViewer.php';
<?php
Breadcrumbs::register('admin.menus.index', function ($breadcrumbs) {
$breadcrumbs->parent('admin.dashboard');
$breadcrumbs->push(trans('menus.backend.menus.management'), route('admin.menus.index'));
});
Breadcrumbs::register('admin.menus.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.menus.index');
$breadcrumbs->push(trans('menus.backend.menus.create'), route('admin.menus.create'));
});
Breadcrumbs::register('admin.menus.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.menus.index');
$breadcrumbs->push(trans('menus.backend.menus.edit'), route('admin.menus.edit', $id));
});
<?php
Breadcrumbs::register('admin.modules.index', function ($breadcrumbs) {
$breadcrumbs->parent('admin.dashboard');
$breadcrumbs->push(trans('menus.backend.modules.management'), route('admin.modules.index'));
});
Breadcrumbs::register('admin.modules.create', function ($breadcrumbs) {
$breadcrumbs->parent('admin.modules.index');
$breadcrumbs->push(trans('menus.backend.modules.create'), route('admin.modules.create'));
});
Breadcrumbs::register('admin.modules.edit', function ($breadcrumbs, $id) {
$breadcrumbs->parent('admin.modules.index');
$breadcrumbs->push(trans('menus.backend.modules.edit'), route('admin.modules.edit', $id));
});
<?php
namespace App\Http\Controllers\Backend\Menu;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Menu\CreateMenuRequest;
use App\Http\Requests\Backend\Menu\DeleteMenuRequest;
use App\Http\Requests\Backend\Menu\EditMenuRequest;
use App\Http\Requests\Backend\Menu\ManageMenuRequest;
use App\Http\Requests\Backend\Menu\StoreMenuRequest;
use App\Http\Requests\Backend\Menu\UpdateMenuRequest;
use App\Models\Menu\Menu;
use App\Repositories\Backend\Menu\MenuRepository;
use Illuminate\Support\Facades\DB;
class MenuController extends Controller
{
/**
* @var MenuRepository
*/
protected $menu;
/**
* @param MenuRepository $menu
*/
public function __construct(MenuRepository $menu)
{
$this->menu = $menu;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(ManageMenuRequest $request)
{
return view('backend.menus.index');
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create(CreateMenuRequest $request)
{
$types = [
'backend' => 'Backend',
'frontend' => 'Frontend',
];
$modules = DB::table('modules')->get();
return view('backend.menus.create')->withTypes($types)->withModules($modules);
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function store(StoreMenuRequest $request)
{
$this->menu->create($request->all());
return redirect()->route('admin.menus.index')->withFlashSuccess(trans('alerts.backend.menus.created'));
}
/**
* Display the specified resource.
*
* @param \App\Models\Menu\Menu $menu
*
* @return \Illuminate\Http\Response
*/
public function show()
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Menu\Menu $menu
*
* @return \Illuminate\Http\Response
*/
public function edit(Menu $menu, EditMenuRequest $request)
{
$types = [
'backend' => 'Backend',
'frontend' => 'Frontend',
];
$modules = DB::table('modules')->get();
return view('backend.menus.edit')->withTypes($types)
->withMenu($menu)
->withModules($modules);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Menu\Menu $menu
*
* @return \Illuminate\Http\Response
*/
public function update(Menu $menu, UpdateMenuRequest $request)
{
$this->menu->update($menu, $request->all());
return redirect()->route('admin.menus.index')->withFlashSuccess(trans('alerts.backend.menus.updated'));
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Menu\Menu $menu
*
* @return \Illuminate\Http\Response
*/
public function destroy(Menu $menu, DeleteMenuRequest $request)
{
$this->menu->delete($menu);
return redirect()->route('admin.menus.index')->withFlashSuccess(trans('alerts.backend.menus.deleted'));
}
/**
* Get the form for modal popup.
*
* @return \Illuminate\Http\Response
*/
public function getForm($formName, CreateMenuRequest $request)
{
if (in_array($formName, ['_add_custom_url_form'])) {
return view('backend.menus.'.$formName);
}
return abort(404);
}
}
<?php
namespace App\Http\Controllers\Backend\Menu;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Menu\ManageMenuRequest;
use App\Repositories\Backend\Menu\MenuRepository;
use Carbon\Carbon;
use Yajra\DataTables\Facades\DataTables;
/**
* Class MenuTableController.
*/
class MenuTableController extends Controller
{
/**
* @var MenuRepository
*/
protected $menus;
/**
* @param MenuRepository $menus
*/
public function __construct(MenuRepository $menus)
{
$this->menus = $menus;
}
/**
* @param ManageMenuRequest $request
*
* @return mixed
*/
public function __invoke(ManageMenuRequest $request)
{
return Datatables::of($this->menus->getForDataTable())
->escapeColumns(['name'])
->addColumn('type', function ($menus) {
return ucwords($menus->type);
})
->addColumn('created_at', function ($menus) {
return Carbon::parse($menus->created_at)->toDateTimeString();
})
->addColumn('updated_at', function ($menus) {
return Carbon::parse($menus->updated_at)->toDateTimeString();
})
->addColumn('actions', function ($menus) {
return $menus->action_buttons;
})
->make(true);
}
}
<?php
namespace App\Http\Controllers\Backend\Module;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Modules\CreateModuleRequest;
use App\Http\Requests\Backend\Modules\ManageModuleRequest;
use App\Http\Requests\Backend\Modules\StoreModuleRequest;
use App\Http\Utilities\Generator;
use App\Models\Access\Permission\Permission;
use App\Models\Module\Module;
use App\Repositories\Backend\Module\ModuleRepository;
use Illuminate\Http\Request;
/**
* Class ModuleController.
*
* @author Vipul Basapati <basapativipulkumar@gmail.com | https://github.com/bvipul>
*/
class ModuleController extends Controller
{
public $repository;
public $generator;
public $event_namespace = 'app\\Events\\Backend\\';
/**
* Constructor.
*
* @param ModuleRepository $repository
*/
public function __construct(ModuleRepository $repository)
{
$this->repository = $repository;
$this->generator = new Generator();
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(ManageModuleRequest $request)
{
return view('backend.modules.index');
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create(CreateModuleRequest $request)
{
return view('backend.modules.create')
->with('model_namespace', $this->generator->getModelNamespace())
->with('request_namespace', $this->generator->getRequestNamespace())
->with('controller_namespace', $this->generator->getControllerNamespace())
->with('event_namespace', $this->event_namespace)
->with('repo_namespace', $this->generator->getRepoNamespace())
->with('route_path', $this->generator->getRoutePath())
->with('view_path', $this->generator->getViewPath());
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function store(StoreModuleRequest $request)
{
$this->generator->initialize($request->all());
$this->generator->createMigration();
$this->generator->createModel();
$this->generator->createRequests();
$this->generator->createRepository();
$this->generator->createController();
$this->generator->createTableController();
$this->generator->createRouteFiles();
$this->generator->insertToLanguageFiles();
$this->generator->createViewFiles();
$this->generator->createEvents();
//Creating the Module
$this->repository->create($request->all(), $this->generator->getPermissions());
return redirect()->route('admin.modules.index')->withFlashSuccess('Module Generated Successfully!');
}
/**
* Checking the path for a file if exists.
*
* @param Request $request
*/
public function checkNamespace(Request $request)
{
if (isset($request->path)) {
$path = $this->parseModel($request->path);
$path = base_path(trim(str_replace('\\', '/', $request->path)), '\\');
$path = str_replace('App', 'app', $path);
if (file_exists($path.'.php')) {
return response()->json((object) [
'type' => 'error',
'message' => 'File exists Already',
]);
} else {
return response()->json((object) [
'type' => 'success',
'message' => 'File can be generated at this location',
]);
}
} else {
return response()->json((object) [
'type' => 'error',
'message' => 'Please provide some value',
]);
}
}
/**
* Checking if the table exists.
*
* @param Request $request
*/
public function checkTable(Request $request)
{
if ($request->table) {
if (Schema::hasTable($request->table)) {
return response()->json((object) [
'type' => 'error',
'message' => 'Table exists Already',
]);
} else {
return response()->json((object) [
'type' => 'success',
'message' => 'Table Name Available',
]);
}
} else {
return response()->json((object) [
'type' => 'error',
'message' => 'Please provide some value',
]);
}
}
/**
* Checking if the table exists.
*
* @param Request $request
*/
public function checkRoute(Request $request)
{
if ($request->table) {
if (Schema::hasTable($request->table)) {
return response()->json((object) [
'type' => 'error',
'message' => 'Table exists Already',
]);
} else {
return response()->json((object) [
'type' => 'success',
'message' => 'Table Name Available',
]);
}
} else {
return response()->json((object) [
'type' => 'error',
'message' => 'Please provide some value',
]);
}
}
/**
* Get the fully-qualified model class name.
*
* @param string $model
*
* @return string
*/
public function parseModel($model)
{
if (preg_match('([^A-Za-z0-9_/\\\\])', $model)) {
throw new InvalidArgumentException('Name contains invalid characters.');
}
$model = trim(str_replace('/', '\\', $model), '\\');
return $model;
}
public function checkPermission(ManageModuleRequest $request)
{
$permission = $request->permission;
if ($permission) {
$per = Permission::where('name', $permission)->first();
if ($per) {
return response()->json((object) [
'type' => 'success',
'message' => 'Permission Exists',
]);
} else {
return response()->json((object) [
'type' => 'error',
'message' => 'Permission does not exists',
]);
}
} else {
return response()->json((object) [
'type' => 'error',
'message' => 'Please provide some value',
]);
}
}
}
<?php
namespace App\Http\Controllers\Backend\Module;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Modules\ManageModuleRequest;
use App\Repositories\Backend\Module\ModuleRepository;
use Yajra\DataTables\Facades\DataTables;
class ModuleTableController extends Controller
{
/**
* @var ModuleRepository
*/
protected $module;
/**
* @param ModuleRepository $module
*/
public function __construct(ModuleRepository $module)
{
$this->module = $module;
}
/**
* @param ManageModuleRequest $request
*
* @return mixed
*/
public function __invoke(ManageModuleRequest $request)
{
return Datatables::of($this->module->getForDataTable())
->escapeColumns(['name', 'url', 'view_permission_id'])
->addColumn('created_by', function ($module) {
return $module->created_by;
})
->make(true);
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class CreateMenuRequest.
*/
class CreateMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('create-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class DeleteMenuRequest.
*/
class DeleteMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('delete-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class EditMenuRequest.
*/
class EditMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('edit-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class ManageMenuRequest.
*/
class ManageMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('view-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class StoreMenuRequest.
*/
class StoreMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('create-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
'type' => 'required',
];
}
}
<?php
namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class UpdateMenuRequest.
*/
class UpdateMenuRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return access()->allow('edit-menu');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
'type' => 'required',
];
}
}
<?php
namespace App\Http\Requests\Backend\Modules;
use App\Http\Requests\Request;
/**
* Class CreateModuleRequest.
*/
class CreateModuleRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// return access()->allow('create-blog');
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Modules;
use App\Http\Requests\Request;
/**
* Class DeleteModuleRequest.
*/
class DeleteModuleRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// return access()->allow('delete-blog');
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Modules;
use App\Http\Requests\Request;
/**
* Class EditModuleRequest.
*/
class EditModuleRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// return access()->allow('edit-blog');
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Modules;
use App\Http\Requests\Request;
/**
* Class ManageModuleRequest.
*/
class ManageModuleRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// return access()->allow('view-blog');
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}
<?php
namespace App\Http\Requests\Backend\Modules;
use App\Http\Requests\Request;
/**
* Class StoreModuleRequest.
*/
class StoreModuleRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// return access()->allow('create-blog');
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|max:191|unique:modules',
'directory_name' => 'required',
'model_name' => 'required',
];
}
/**
* Get the validation message that apply to the request.
*
* @return array
*/
public function messages()
{
return [
'name.required' => 'Module Name field is required to be filled',
'name.max' => 'Module Name should not exceed 191 characters',
'name.unique' => 'Module Name is already taken',
'directory_name.required' => 'Directory Name field is required to be filled',
'model_name.required' => 'Model Name field is required to be filled',
];
}
}
<?php
namespace App\Http\Requests\Backend\Modules;
use App\Http\Requests\Request;
/**
* Class UpdateModuleRequest.
*/
class UpdateModuleRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// return access()->allow('edit-blog');
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|max:191|unique:modules,name,'.$this->segment(3).',id',
'url' => 'required',
'view_permission_id' => 'required',
];
}
/**
* Get the validation message that apply to the request.
*
* @return array
*/
public function messages()
{
return [
];
}
}
<?php
namespace App\Http\Utilities;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schema;
/**
* Class Generator.
*
* @author Vipul Basapati <basapativipulkumar@gmail.com | https://github.com/bvipul>
*/
class Generator
{
/**
* Module Name.
*/
protected $module;
/**
* Files Object.
*/
protected $files;
/**
* Directory Name.
*/
protected $directory;
/**
* ----------------------------------------------------------------------------------------------
* Model Related Files
* -----------------------------------------------------------------------------------------------
* 1. Model Name
* 2. Attribute Name
* 3. Relationship Name
* 4. Attribute Namespace
* 5. Relationship Namespace
* 6. Traits directory
* 7. Model Namespace.
*/
protected $model;
protected $attribute;
protected $relationship;
protected $attribute_namespace;
protected $relationship_namespace;
protected $trait_directory = 'Traits';
protected $model_namespace = 'App\\Models\\';
/**
* Controllers
* 1. Controlller Name
* 2. Table Controller Name
* 3. Controller Namespace
* 4. Table Controller Namespace.
*/
protected $controller;
protected $table_controller;
protected $controller_namespace = 'App\\Http\\Controllers\\Backend\\';
protected $table_controller_namespace = 'App\\Http\\Controllers\\Backend\\';
/**
* Requests
* 1. Edit Request Name
* 2. Store Request Name
* 3. Create Request Name
* 4. Update Request Name
* 5. Delete Request Name
* 6. Manage Request Name
* 7. Edit Request Namespace
* 8. Store Request Namespace
* 9. Manage Request Namespace
* 10. Create Request Namespace
* 11. Update Request Namespace
* 12. Delete Request Namespace
* 13. Request Namespace.
*/
protected $edit_request;
protected $store_request;
protected $create_request;
protected $update_request;
protected $delete_request;
protected $manage_request;
protected $edit_request_namespace;
protected $store_request_namespace;
protected $manage_request_namespace;
protected $create_request_namespace;
protected $update_request_namespace;
protected $delete_request_namespace;
protected $request_namespace = 'App\\Http\\Requests\\Backend\\';
/**
* Permissions
* 1. Edit Permission
* 2. Store Permission
* 3. Manage Permission
* 4. Create Permission
* 5. Update Permission
* 6. Delete Permission.
*/
protected $edit_permission;
protected $store_permission;
protected $manage_permission;
protected $create_permission;
protected $update_permission;
protected $delete_permission;
/**
* Routes
* 1. Edit Route
* 2. Store Route
* 3. Manage Route
* 4. Create Route
* 5. Update Route
* 6. Delete Route.
*/
protected $edit_route;
protected $store_route;
protected $index_route;
protected $create_route;
protected $update_route;
protected $delete_route;
/**
* Repository
* 1. Repository Name
* 2. Repository Namespace.
*/
protected $repository;
protected $repo_namespace = 'App\\Repositories\\Backend\\';
/**
* Table Name.
*/
protected $table;
/**
* Events.
*
* @var array
*/
protected $events = [];
/**
* Route Path.
*/
protected $route_path = 'routes\\Backend\\';
/**
* View Path.
*/
protected $view_path = 'resources\\views\\backend\\';
/**
* Event Namespace.
*/
protected $event_namespace = 'Backend\\';
/**
* Constructor.
*/
public function __construct()
{
$this->files = new Filesystem();
}
/**
* Initialization.
*
* @param array $input
*/
public function initialize($input)
{
//Module
$this->module = title_case($input['name']);
//Directory
$this->directory = str_singular(title_case($input['directory_name']));
//Model
$this->model = str_singular(title_case($input['model_name']));
//Table
$this->table = str_plural(strtolower($input['table_name']));
//Controller
$this->controller = str_plural($this->model).'Controller';
//Table Controller
$this->table_controller = str_plural($this->model).'TableController';
//Attributes
$this->attribute = $this->model.'Attribute';
$this->attribute_namespace = $this->model_namespace;
//Relationship
$this->relationship = $this->model.'Relationship';
$this->relationship_namespace = $this->model_namespace;
//Repository
$this->repository = $this->model.'Repository';
//Requests
$this->edit_request = 'Edit'.$this->model.'Request';
$this->store_request = 'Store'.$this->model.'Request';
$this->create_request = 'Create'.$this->model.'Request';
$this->update_request = 'Update'.$this->model.'Request';
$this->delete_request = 'Delete'.$this->model.'Request';
$this->manage_request = 'Manage'.$this->model.'Request';
//CRUD Options
$this->edit = !empty($input['model_edit']) ? true : false;
$this->create = !empty($input['model_create']) ? true : false;
$this->delete = !empty($input['model_delete']) ? true : false;
//Permissions
$this->edit_permission = 'edit-'.strtolower(str_singular($this->model));
$this->store_permission = 'store-'.strtolower(str_singular($this->model));
$this->manage_permission = 'manage-'.strtolower(str_singular($this->model));
$this->create_permission = 'create-'.strtolower(str_singular($this->model));
$this->update_permission = 'update-'.strtolower(str_singular($this->model));
$this->delete_permission = 'delete-'.strtolower(str_singular($this->model));
//Routes
$this->index_route = 'admin.'.strtolower(str_plural($this->model)).'.index';
$this->create_route = 'admin.'.strtolower(str_plural($this->model)).'.create';
$this->store_route = 'admin.'.strtolower(str_plural($this->model)).'.store';
$this->edit_route = 'admin.'.strtolower(str_plural($this->model)).'.edit';
$this->update_route = 'admin.'.strtolower(str_plural($this->model)).'.update';
$this->delete_route = 'admin.'.strtolower(str_plural($this->model)).'.destroy';
//Events
$this->events = array_filter($input['event']);
//Generate Namespaces
$this->createNamespacesAndValues();
}
/**
* @return void
*/
private function createNamespacesAndValues()
{
//Model Namespace
$this->model_namespace .= $this->getFullNamespace($this->model);
//Controller Namespace
$this->controller_namespace .= $this->getFullNamespace($this->controller);
//Table Controller Namespace
$this->table_controller_namespace .= $this->getFullNamespace($this->table_controller);
//Attribute Namespace
$this->attribute_namespace .= $this->getFullNamespace($this->attribute, $this->trait_directory);
//Relationship Namespace
$this->relationship_namespace .= $this->getFullNamespace($this->relationship, $this->trait_directory);
//View Path
$this->view_path .= $this->getFullNamespace('');
//Requests
$this->edit_request_namespace = $this->request_namespace.$this->getFullNamespace($this->edit_request);
$this->store_request_namespace = $this->request_namespace.$this->getFullNamespace($this->store_request);
$this->manage_request_namespace = $this->request_namespace.$this->getFullNamespace($this->manage_request);
$this->create_request_namespace = $this->request_namespace.$this->getFullNamespace($this->create_request);
$this->update_request_namespace = $this->request_namespace.$this->getFullNamespace($this->update_request);
$this->delete_request_namespace = $this->request_namespace.$this->getFullNamespace($this->delete_request);
//Repository Namespace
$this->repo_namespace .= $this->getFullNamespace($this->repository);
//Events Namespace
$this->event_namespace .= $this->getFullNamespace('');
}
/**
* @return string
*/
public function getModelNamespace()
{
return $this->model_namespace;
}
/**
* @return string
*/
public function getRequestNamespace()
{
return $this->request_namespace;
}
/**
* @return string
*/
public function getControllerNamespace()
{
return $this->controller_namespace;
}
/**
* @return string
*/
public function getRepoNamespace()
{
return $this->repo_namespace;
}
/**
* @return string
*/
public function getRoutePath()
{
return $this->route_path;
}
/**
* @return string
*/
public function getViewPath()
{
return $this->view_path;
}
/**
* Return the permissions used in the module.
*
* @return array
*/
public function getPermissions()
{
$permissions = [];
if ($this->create) {
$permissions[] = $this->create_permission;
$permissions[] = $this->store_permission;
}
if ($this->edit) {
$permissions[] = $this->edit_permission;
$permissions[] = $this->update_permission;
}
if ($this->delete) {
$permissions[] = $this->delete_permission;
}
return $permissions;
}
/**
* @return string
*/
public function getFullNamespace($name, $inside_directory = null)
{
if (empty($name)) {
return $this->directory;
} elseif ($inside_directory) {
return $this->directory.'\\'.$inside_directory.'\\'.$name;
} else {
return $this->directory.'\\'.$name;
}
}
/**
* @return void
*/
public function createModel()
{
$this->createDirectory($this->getBasePath($this->removeFileNameFromEndOfNamespace($this->attribute_namespace)));
//Generate Attribute File
$this->generateFile('Attribute', [
'AttributeNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->attribute_namespace)),
'AttributeClass' => $this->attribute,
'editPermission' => $this->edit_permission,
'editRoute' => $this->edit_route,
'deletePermission' => $this->delete_permission,
'deleteRoute' => $this->delete_route,
], lcfirst($this->attribute_namespace));
//Generate Relationship File
$this->generateFile('Relationship', [
'RelationshipNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->relationship_namespace)),
'RelationshipClass' => $this->relationship,
], lcfirst($this->relationship_namespace));
//Generate Model File
$this->generateFile('Model', [
'DummyNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->model_namespace)),
'DummyAttribute' => $this->attribute_namespace,
'DummyRelationship' => $this->relationship_namespace,
'AttributeName' => $this->attribute,
'RelationshipName' => $this->relationship,
'DummyModel' => $this->model,
'table_name' => $this->table,
], lcfirst($this->model_namespace));
}
/**
* @return void
*/
public function createDirectory($path)
{
$this->files->makeDirectory($path, 0777, true, true);
}
/**
* @return void
*/
public function createRequests()
{
$this->request_namespace .= $this->getFullNamespace('');
$this->createDirectory($this->getBasePath($this->request_namespace));
// dd('here');
//Generate Manage Request File
$this->generateFile('Request', [
'DummyNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->manage_request_namespace)),
'DummyClass' => $this->manage_request,
'permission' => $this->manage_permission,
], lcfirst($this->manage_request_namespace));
if ($this->create) {
//Generate Create Request File
$this->generateFile('Request', [
'DummyNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->create_request_namespace)),
'DummyClass' => $this->create_request,
'permission' => $this->create_permission,
], lcfirst($this->create_request_namespace));
//Generate Store Request File
$this->generateFile('Request', [
'DummyNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->store_request_namespace)),
'DummyClass' => $this->store_request,
'permission' => $this->store_permission,
], lcfirst($this->store_request_namespace));
}
if ($this->edit) {
//Generate Edit Request File
$this->generateFile('Request', [
'DummyNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->edit_request_namespace)),
'DummyClass' => $this->edit_request,
'permission' => $this->edit_permission,
], lcfirst($this->edit_request_namespace));
//Generate Update Request File
$this->generateFile('Request', [
'DummyNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->update_request_namespace)),
'DummyClass' => $this->update_request,
'permission' => $this->update_permission,
], lcfirst($this->update_request_namespace));
}
if ($this->delete) {
//Generate Delete Request File
$this->generateFile('Request', [
'DummyNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->delete_request_namespace)),
'DummyClass' => $this->delete_request,
'permission' => $this->delete_permission,
], lcfirst($this->delete_request_namespace));
}
}
/**
* @return void
*/
public function createRepository()
{
$this->createDirectory($this->getBasePath($this->repo_namespace));
//Getting stub file content
$file_contents = $this->files->get($this->getStubPath().'Repository.stub');
//If Model Create is checked
if (!$this->create) {
$file_contents = $this->delete_all_between('@startCreate', '@endCreate', $file_contents);
} else {//If it isn't
$file_contents = $this->delete_all_between('@startCreate', '@startCreate', $file_contents);
$file_contents = $this->delete_all_between('@endCreate', '@endCreate', $file_contents);
}
//If Model Edit is Checked
if (!$this->edit) {
$file_contents = $this->delete_all_between('@startEdit', '@endEdit', $file_contents);
} else {//If it isn't
$file_contents = $this->delete_all_between('@startEdit', '@startEdit', $file_contents);
$file_contents = $this->delete_all_between('@endEdit', '@endEdit', $file_contents);
}
//If Model Delete is Checked
if (!$this->delete) {
$file_contents = $this->delete_all_between('@startDelete', '@endDelete', $file_contents);
} else {//If it isn't
$file_contents = $this->delete_all_between('@startDelete', '@startDelete', $file_contents);
$file_contents = $this->delete_all_between('@endDelete', '@endDelete', $file_contents);
}
//Replacements to be done in repository stub file
$replacements = [
'DummyNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->repo_namespace)),
'DummyModelNamespace' => $this->model_namespace,
'DummyRepoName' => $this->repository,
'dummy_model_name' => $this->model,
'dummy_small_model_name' => strtolower($this->model),
'model_small_plural' => strtolower(str_plural($this->model)),
'dummy_small_plural_model_name' => strtolower(str_plural($this->model)),
];
//Generating the repo file
$this->generateFile(false, $replacements, lcfirst($this->repo_namespace), $file_contents);
}
/**
* @return void
*/
public function createController()
{
// dd($this->controller_namespace);
$this->createDirectory($this->getBasePath($this->controller_namespace, true));
//Getting stub file content
$file_contents = $this->files->get($this->getStubPath().'Controller.stub');
//Replacements to be done in controller stub
$replacements = [
'DummyModelNamespace' => $this->model_namespace,
'DummyModel' => $this->model,
'DummyArgumentName' => strtolower($this->model),
'DummyManageRequestNamespace' => $this->manage_request_namespace,
'DummyManageRequest' => $this->manage_request,
'DummyController' => $this->controller,
'DummyNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->controller_namespace)),
'DummyRepositoryNamespace' => $this->repo_namespace,
'dummy_repository' => $this->repository,
'dummy_small_plural_model' => strtolower(str_plural($this->model)),
];
$namespaces = '';
if (!$this->create) {
$file_contents = $this->delete_all_between('@startCreate', '@endCreate', $file_contents);
} else {
$file_contents = $this->delete_all_between('@startCreate', '@startCreate', $file_contents);
$file_contents = $this->delete_all_between('@endCreate', '@endCreate', $file_contents);
//replacements
$namespaces .= 'use '.$this->create_request_namespace.";\n";
$namespaces .= 'use '.$this->store_request_namespace.";\n";
$replacements['DummyCreateRequest'] = $this->create_request;
$replacements['DummyStoreRequest'] = $this->store_request;
}
if (!$this->edit) {
$file_contents = $this->delete_all_between('@startEdit', '@endEdit', $file_contents);
} else {
$file_contents = $this->delete_all_between('@startEdit', '@startEdit', $file_contents);
$file_contents = $this->delete_all_between('@endEdit', '@endEdit', $file_contents);
//replacements
$namespaces .= 'use '.$this->edit_request_namespace.";\n";
$namespaces .= 'use '.$this->update_request_namespace.";\n";
$replacements['DummyEditRequest'] = $this->edit_request;
$replacements['DummyUpdateRequest'] = $this->update_request;
}
if (!$this->delete) {
$file_contents = $this->delete_all_between('@startDelete', '@endDelete', $file_contents);
} else {
$file_contents = $this->delete_all_between('@startDelete', '@startDelete', $file_contents);
$file_contents = $this->delete_all_between('@endDelete', '@endDelete', $file_contents);
//replacements
$namespaces .= 'use '.$this->delete_request_namespace.";\n";
$replacements['DummyDeleteRequest'] = $this->delete_request;
}
//Putting Namespaces in Controller
$file_contents = str_replace('@Namespaces', $namespaces, $file_contents);
$this->generateFile(false, $replacements, lcfirst($this->controller_namespace), $file_contents);
}
/**
* @return void
*/
public function createTableController()
{
$this->createDirectory($this->getBasePath($this->table_controller_namespace, true));
//replacements to be done in table controller stub
$replacements = [
'DummyNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->table_controller_namespace)),
'DummyRepositoryNamespace' => $this->repo_namespace,
'DummyManageRequestNamespace' => $this->manage_request_namespace,
'DummyTableController' => $this->table_controller,
'dummy_repository' => $this->repository,
'dummy_small_repo_name' => strtolower($this->model),
'dummy_manage_request_name' => $this->manage_request,
];
//generating the file
$this->generateFile('TableController', $replacements, lcfirst($this->table_controller_namespace));
}
/**
* @return void
*/
public function createRouteFiles()
{
$this->createDirectory($this->getBasePath($this->route_path));
if ($this->create && $this->edit && $this->delete) {//Then get the resourceRoute stub
//Getting stub file content
$file_contents = $this->files->get($this->getStubPath().'resourceRoute.stub');
$file_contents = $this->delete_all_between('@startNamespace', '@startNamespace', $file_contents);
$file_contents = $this->delete_all_between('@endNamespace', '@endNamespace', $file_contents);
$file_contents = $this->delete_all_between('@startWithoutNamespace', '@endWithoutNamespace', $file_contents);
} else {//Get the basic route stub
//Getting stub file content
$file_contents = $this->files->get($this->getStubPath().'route.stub');
$file_contents = $this->delete_all_between('@startNamespace', '@startNamespace', $file_contents);
$file_contents = $this->delete_all_between('@endNamespace', '@endNamespace', $file_contents);
$file_contents = $this->delete_all_between('@startWithoutNamespace', '@endWithoutNamespace', $file_contents);
//If create is checked
if ($this->create) {
$file_contents = $this->delete_all_between('@startCreate', '@startCreate', $file_contents);
$file_contents = $this->delete_all_between('@endCreate', '@endCreate', $file_contents);
} else {//If it isn't
$file_contents = $this->delete_all_between('@startCreate', '@endCreate', $file_contents);
}
//If Edit is checked
if ($this->edit) {
$file_contents = $this->delete_all_between('@startEdit', '@startEdit', $file_contents);
$file_contents = $this->delete_all_between('@endEdit', '@endEdit', $file_contents);
} else {//if it isn't
$file_contents = $this->delete_all_between('@startEdit', '@endEdit', $file_contents);
}
//If delete is checked
if ($this->delete) {
$file_contents = $this->delete_all_between('@startDelete', '@startDelete', $file_contents);
$file_contents = $this->delete_all_between('@endDelete', '@endDelete', $file_contents);
} else {//If it isn't
$file_contents = $this->delete_all_between('@startDelete', '@endDelete', $file_contents);
}
}
//Generate the Route file
$this->generateFile(false, [
'DummyModuleName' => $this->module,
'DummyModel' => $this->directory,
'dummy_name' => strtolower(str_plural($this->model)),
'DummyController' => $this->controller,
'DummyTableController' => $this->table_controller,
'dummy_argument_name' => strtolower($this->model),
], $this->route_path.$this->model, $file_contents);
}
/**
* This would enter the necessary language file contents to respective language files.
*
* @param [array] $input
*/
public function insertToLanguageFiles()
{
//Model singular version
$model_singular = ucfirst(str_singular($this->model));
//Model Plural version
$model_plural = strtolower(str_plural($this->model));
//Model plural with capitalize
$model_plural_capital = ucfirst($model_plural);
//Findind which locale is being used
$locale = config('app.locale');
//Path to that language files
$path = resource_path('lang'.DIRECTORY_SEPARATOR.$locale);
//config folder path
$config_path = config_path('module.php');
//Creating directory if it isn't
$this->createDirectory($path);
//Labels file
$labels = [
'create' => "Create $model_singular",
'edit' => "Edit $model_singular",
'management' => "$model_singular Management",
'title' => "$model_plural_capital",
'table' => [
'id' => 'Id',
'createdat' => 'Created At',
],
];
//Pushing values to labels
add_key_value_in_file($path.'/labels.php', [$model_plural => $labels], 'backend');
//Menus file
$menus = [
'all' => "All $model_plural_capital",
'create' => "Create $model_singular",
'edit' => "Edit $model_singular",
'management' => "$model_singular Management",
'main' => "$model_plural_capital",
];
//Pushing to menus file
add_key_value_in_file($path.'/menus.php', [$model_plural => $menus], 'backend');
//Exceptions file
$exceptions = [
'already_exists' => "That $model_singular already exists. Please choose a different name.",
'create_error' => "There was a problem creating this $model_singular. Please try again.",
'delete_error' => "There was a problem deleting this $model_singular. Please try again.",
'not_found' => "That $model_singular does not exist.",
'update_error' => "There was a problem updating this $model_singular. Please try again.",
];
//Alerts File
$alerts = [
'created' => "The $model_singular was successfully created.",
'deleted' => "The $model_singular was successfully deleted.",
'updated' => "The $model_singular was successfully updated.",
];
//Pushing to menus file
add_key_value_in_file($path.'/alerts.php', [$model_plural => $alerts], 'backend');
//Pushing to exceptions file
add_key_value_in_file($path.'/exceptions.php', [$model_plural => $exceptions], 'backend');
//config file "module.php"
$config = [
$model_plural => [
'table' => $this->table,
],
];
//Pushing to config file
add_key_value_in_file($config_path, $config);
}
/**
* Creating View Files.
*
* @param array $input
*/
public function createViewFiles()
{
//Getiing model
$model = $this->model;
//lowercase version of model
$model_lower = strtolower($model);
//lowercase and plural version of model
$model_lower_plural = str_plural($model_lower);
//View folder name
$view_folder_name = $model_lower_plural;
//View path
$path = escapeSlashes(strtolower(str_plural($this->view_path)));
//Header buttons folder
$header_button_path = $path.DIRECTORY_SEPARATOR.'partials';
//This would create both the directory name as well as partials inside of that directory
$this->createDirectory(base_path($header_button_path));
//Header button full path
$header_button_file_path = $header_button_path.DIRECTORY_SEPARATOR."$model_lower_plural-header-buttons.blade";
//Getting stub file content
$header_button_contents = $this->files->get($this->getStubPath().'header-buttons.stub');
if (!$this->create) {
$header_button_contents = $this->delete_all_between('@create', '@endCreate', $header_button_contents);
} else {
$header_button_contents = $this->delete_all_between('@create', '@create', $header_button_contents);
$header_button_contents = $this->delete_all_between('@endCreate', '@endCreate', $header_button_contents);
}
//Generate Header buttons file
$this->generateFile(false, ['dummy_small_plural_model' => $model_lower_plural, 'dummy_small_model' => $model_lower], $header_button_file_path, $header_button_contents);
//Index blade
$index_path = $path.DIRECTORY_SEPARATOR.'index.blade';
//Generate the Index blade file
$this->generateFile('index_view', ['dummy_small_plural_model' => $model_lower_plural], $index_path);
//Create Blade
if ($this->create) {
//Create Blade
$create_path = $path.DIRECTORY_SEPARATOR.'create.blade';
//Generate Create Blade
$this->generateFile('create_view', ['dummy_small_plural_model' => $model_lower_plural, 'dummy_small_model' => $model_lower], $create_path);
}
//Edit Blade
if ($this->edit) {
//Edit Blade
$edit_path = $path.DIRECTORY_SEPARATOR.'edit.blade';
//Generate Edit Blade
$this->generateFile('edit_view', ['dummy_small_plural_model' => $model_lower_plural, 'dummy_small_model' => $model_lower], $edit_path);
}
//Form Blade
if ($this->create || $this->edit) {
//Form Blade
$form_path = $path.DIRECTORY_SEPARATOR.'form.blade';
//Generate Form Blade
$this->generateFile('form_view', [], $form_path);
}
//BreadCrumbs Folder Path
$breadcrumbs_path = escapeSlashes('app\\Http\\Breadcrumbs\\Backend');
//Breadcrumb File path
$breadcrumb_file_path = $breadcrumbs_path.DIRECTORY_SEPARATOR.$this->model;
//Generate BreadCrumb File
$this->generateFile('Breadcrumbs', ['dummy_small_plural_model' => $model_lower_plural], $breadcrumb_file_path);
//Backend File of Breadcrumb
$breadcrumb_backend_file = $breadcrumbs_path.DIRECTORY_SEPARATOR.'Backend.php';
//file_contents of Backend.php
$file_contents = file_get_contents(base_path($breadcrumb_backend_file));
//If this is already not there, then only append
if (!strpos($file_contents, "require __DIR__.'/$this->model.php';")) {
//Appending into BreadCrumb backend file
file_put_contents(base_path($breadcrumb_backend_file), "\nrequire __DIR__.'/$this->model.php';", FILE_APPEND);
}
}
/**
* Creating Table File.
*
* @param array $input
*/
public function createMigration()
{
$table = $this->table;
if (Schema::hasTable($table)) {
return 'Table Already Exists!';
} else {
//Calling Artisan command to create table
Artisan::call('make:migration', [
'name' => 'create_'.$table.'_table',
'--create' => $table,
]);
return Artisan::output();
}
}
/**
* Creating Event Files.
*
* @param array $input
*/
public function createEvents()
{
if (!empty($this->events)) {
$base_path = $this->event_namespace;
foreach ($this->events as $event) {
$path = escapeSlashes($base_path.DIRECTORY_SEPARATOR.$event);
$model = str_replace(DIRECTORY_SEPARATOR, '\\', $path);
Artisan::call('make:event', [
'name' => $model,
]);
Artisan::call('make:listener', [
'name' => $model.'Listener',
'--event' => $model,
]);
}
}
}
/**
* Generating the file by
* replacing placeholders in stub file.
*
* @param $stub_name Name of the Stub File
* @param $replacements [array] Array of the replacement to be done in stub file
* @param $file [string] full path of the file
* @param $contents [string][optional] file contents
*/
public function generateFile($stub_name, $replacements, $file, $contents = null)
{
if ($stub_name) {
//Getting the Stub Files Content
$file_contents = $this->files->get($this->getStubPath().$stub_name.'.stub');
} else {
//Getting the Stub Files Content
$file_contents = $contents;
}
//Replacing the stub
$file_contents = str_replace(
array_keys($replacements),
array_values($replacements),
$file_contents
);
$this->files->put(base_path(escapeSlashes($file)).'.php', $file_contents);
}
/**
* getting the stub folder path.
*
* @return string
*/
public function getStubPath()
{
return app_path('Console'.DIRECTORY_SEPARATOR.'Commands'.DIRECTORY_SEPARATOR.'Stubs'.DIRECTORY_SEPARATOR);
}
public function getBasePath($namespace, $status = false)
{
if ($status) {
return base_path(escapeSlashes($this->removeFileNameFromEndOfNamespace($namespace, $status)));
}
return base_path(lcfirst(escapeSlashes($namespace)));
}
public function removeFileNameFromEndOfNamespace($namespace)
{
$namespace = explode('\\', $namespace);
unset($namespace[count($namespace) - 1]);
return lcfirst(implode('\\', $namespace));
}
public function appendFileNameToEndOfNamespace($namespace, $file)
{
return escapeSlashes($namespace.DIRECTORY_SEPARATOR.$file);
}
/**
* Modify strings by removing content between $beginning and $end.
*
* @param string $beginning
* @param string $end
* @param string $string
*
* @return string
*/
public function delete_all_between($beginning, $end, $string)
{
$beginningPos = strpos($string, $beginning);
$endPos = strpos($string, $end);
if ($beginningPos === false || $endPos === false) {
return $string;
}
$textToDelete = substr($string, $beginningPos, ($endPos + strlen($end)) - $beginningPos);
return str_replace($textToDelete, '', $string);
}
}
<?php
namespace App\Models\Menu;
use App\Models\Menu\Traits\Attribute\MenuAttribute;
use App\Models\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Menu extends Model
{
use ModelTrait,
SoftDeletes,
MenuAttribute {
// MenuAttribute::getEditButtonAttribute insteadof ModelTrait;
}
/**
* The database table used by the model.
*
* @var string
*/
protected $table;
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->table = config('access.menus_table');
}
}
<?php
namespace App\Models\Menu\Traits\Attribute;
/**
* Class MenuAttribute.
*/
trait MenuAttribute
{
/**
* @return string
*/
public function getActionButtonsAttribute()
{
return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute('edit-menu', 'admin.menus.edit').'
'.$this->getDeleteButtonAttribute('delete-menu', 'admin.menus.destroy').'
</div>';
}
}
<?php
namespace App\Models\Module;
use App\Models\Module\Traits\Attribute\ModuleAttribute;
use Illuminate\Database\Eloquent\Model;
class Module extends Model
{
use ModuleAttribute;
protected $table = 'modules';
protected $fillable = ['view_permission_id', 'name', 'url', 'created_by', 'updated_by'];
}
<?php
namespace App\Models\Module\Traits\Attribute;
/**
* Class ModuleAttribute.
*/
trait ModuleAttribute
{
/**
* @return string
*/
public function getEditButtonAttribute()
{
// if(access()->allow('edit-blog'))
// {
return '<a href="'.route('admin.modules.edit', $this).'" class="btn btn-flat btn-default">
<i data-toggle="tooltip" data-placement="top" title="Edit" class="fa fa-pencil"></i>
</a>';
// }
}
/**
* @return string
*/
public function getDeleteButtonAttribute()
{
// if(access()->allow('delete-blog'))
// {
return '<a href="'.route('admin.blogs.destroy', $this).'"
class="btn btn-flat btn-default" data-method="delete"
data-trans-button-cancel="'.trans('buttons.general.cancel').'"
data-trans-button-confirm="'.trans('buttons.general.crud.delete').'"
data-trans-title="'.trans('strings.backend.general.are_you_sure').'">
<i data-toggle="tooltip" data-placement="top" title="Delete" class="fa fa-trash"></i>
</a>';
// }
}
/**
* @return string
*/
public function getActionButtonsAttribute()
{
return '<div class="btn-group action-btn">'.
$this->getEditButtonAttribute().
// $this->getDeleteButtonAttribute().
'</div>';
}
}
<?php
namespace App\Repositories\Backend\Menu;
use App\Exceptions\GeneralException;
use App\Models\Menu\Menu;
use App\Repositories\BaseRepository;
use DB;
//use App\Events\Backend\CMSPages\CMSPageCreated;
//use App\Events\Backend\CMSPages\CMSPageDeleted;
//use App\Events\Backend\CMSPages\CMSPageUpdated;
use Illuminate\Database\Eloquent\Model;
/**
* Class MenuRepository.
*/
class MenuRepository extends BaseRepository
{
/**
* Associated Repository Model.
*/
const MODEL = Menu::class;
/**
* @return mixed
*/
public function getForDataTable()
{
return $this->query()
->select([
config('access.menus_table').'.id',
config('access.menus_table').'.name',
config('access.menus_table').'.type',
config('access.menus_table').'.created_at',
config('access.menus_table').'.updated_at',
]);
}
/**
* @param array $input
*
* @throws GeneralException
*
* @return bool
*/
public function create(array $input)
{
if ($this->query()->where('name', $input['name'])->first()) {
throw new GeneralException(trans('exceptions.backend.menus.already_exists'));
}
$menu = self::MODEL;
$menu = new $menu();
$menu->name = $input['name'];
$menu->type = $input['type'];
$menu->items = $input['items'];
$menu->created_by = access()->user()->id;
DB::transaction(function () use ($input, $menu) {
if ($menu->save()) {
//event(new CMSPageCreated($menu));
return true;
}
throw new GeneralException(trans('exceptions.backend.menus.create_error'));
});
}
/**
* @param Model $permission
* @param $input
*
* @throws GeneralException
*
* return bool
*/
public function update(Model $menu, array $input)
{
if ($this->query()->where('name', $input['name'])->where('id', '!=', $menu->id)->first()) {
throw new GeneralException(trans('exceptions.backend.menus.already_exists'));
}
$menu->name = $input['name'];
$menu->type = $input['type'];
$menu->items = $input['items'];
$menu->updated_by = access()->user()->id;
DB::transaction(function () use ($menu, $input) {
if ($menu->save()) {
//event(new CMSPageUpdated($menu));
return true;
}
throw new GeneralException(trans('exceptions.backend.menus.update_error'));
});
}
/**
* @param Model $cmspage
*
* @throws GeneralException
*
* @return bool
*/
public function delete(Model $menu)
{
DB::transaction(function () use ($menu) {
if ($menu->delete()) {
//event(new CMSPageDeleted($menu));
return true;
}
throw new GeneralException(trans('exceptions.backend.menus.delete_error'));
});
}
}
<?php
namespace App\Repositories\Backend\Module;
use App\Exceptions\GeneralException;
use App\Models\Access\Permission\Permission;
use App\Models\Module\Module;
use App\Repositories\BaseRepository;
/**
* Class ModuleRepository.
*/
class ModuleRepository extends BaseRepository
{
/**
* Associated Repository Model.
*/
const MODEL = Module::class;
/**
* @return mixed
*/
public function getForDataTable()
{
return $this->query()
->leftjoin(config('access.users_table'), config('access.users_table').'.id', '=', config('module.table').'.created_by')
->select([
config('module.table').'.id',
config('module.table').'.name',
config('module.table').'.url',
config('module.table').'.view_permission_id',
config('module.table').'.created_by',
config('module.table').'.updated_by',
config('access.users_table').'.first_name as created_by',
]);
}
/**
* @param array $input
*
* @throws GeneralException
*
* @return bool
*/
public function create(array $input, array $permissions)
{
$module = Module::where('name', $input['name'])->first();
if (!$module) {
$name = $input['model_name'];
$model = strtolower($name);
// $permissions =
// [
// ['name' => "view-$model-permission", 'display_name' => 'View '.ucwords($model).' Permission'],
// ['name' => "create-$model-permission", 'display_name' => 'Create '.ucwords($model).' Permission'],
// ['name' => "edit-$model-permission", 'display_name' => 'Edit '.ucwords($model).' Permission'],
// ['name' => "delete-$model-permission", 'display_name' => 'Delete '.ucwords($model).' Permission'],
// ];
foreach ($permissions as $permission) {
$perm = [
'name' => $permission,
'display_name' => title_case(str_replace('-', ' ', $permission)).' Permission',
];
//Creating Permission
$per = Permission::firstOrCreate($perm);
}
$mod = [
'view_permission_id' => "view-$model-permission",
'name' => $input['name'],
'url' => 'admin.'.str_plural($model).'.index',
'created_by' => access()->user()->id,
];
$create = Module::create($mod);
return $create;
}
throw new GeneralException(trans('exceptions.backend.modules.create_error'));
}
/**
* @param $module
* @param $input
*
* @throws GeneralException
*
* @return bool
*/
public function update($module, array $input)
{
$module->name = $input['name'];
$module->view_permission_id = $input['view_permission_id'];
$module->url = $input['url'];
$module->updated_by = access()->user()->id;
if ($module->update()) {
return true;
}
throw new GeneralException(
trans('exceptions.backend.modules.update_error')
);
}
}
......@@ -14,18 +14,19 @@
"arcanedev/no-captcha": "^5.0",
"creativeorange/gravatar": "~1.0",
"davejamesmiller/laravel-breadcrumbs": "^4.1",
"doctrine/dbal": "^2.5",
"fideloper/proxy": "~3.3",
"hieu-le/active": "^3.5",
"laravel/framework": "5.5.*",
"laravel/socialite": "^3.0",
"laravel/tinker": "~1.0",
"laravelcollective/html": "^5.5.0",
"doctrine/dbal": "^2.5",
"tymon/jwt-auth": "^0.5.12",
"yajra/laravel-datatables-oracle":"~8.0"
"tymon/jwt-auth": "0.5.12",
"yajra/laravel-datatables-oracle": "~8.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.0",
"bvipul/generator": "0.9",
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"laravel/browser-kit-testing": "^1.0",
......@@ -38,7 +39,8 @@
"database"
],
"psr-4": {
"App\\": "app/"
"App\\": "app/",
"Bvipul\\Generator\\": "packages/bvipul/generator/src/"
},
"files": [
"app/Helpers/helpers.php"
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "6ddd07d8806b3ceefd05d8193db4ffaf",
"content-hash": "a3f840cc149b683df286539b607264d9",
"packages": [
{
"name": "arcanedev/log-viewer",
......@@ -1294,16 +1294,16 @@
},
{
"name": "laravel/framework",
"version": "v5.5.20",
"version": "v5.5.21",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "ce0019d22a83b1b240330ea4115ae27a4d75d79c"
"reference": "6321069a75723d88103526903d3192f0b231544a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/ce0019d22a83b1b240330ea4115ae27a4d75d79c",
"reference": "ce0019d22a83b1b240330ea4115ae27a4d75d79c",
"url": "https://api.github.com/repos/laravel/framework/zipball/6321069a75723d88103526903d3192f0b231544a",
"reference": "6321069a75723d88103526903d3192f0b231544a",
"shasum": ""
},
"require": {
......@@ -1377,6 +1377,8 @@
"suggest": {
"aws/aws-sdk-php": "Required to use the SQS queue driver and SES mail driver (~3.0).",
"doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.5).",
"ext-pcntl": "Required to use all features of the queue worker.",
"ext-posix": "Required to use all features of the queue worker.",
"fzaninotto/faker": "Required to use the eloquent factory builder (~1.4).",
"guzzlehttp/guzzle": "Required to use the Mailgun and Mandrill mail drivers and the ping methods on schedules (~6.0).",
"laravel/tinker": "Required to use the tinker console command (~1.0).",
......@@ -1421,7 +1423,7 @@
"framework",
"laravel"
],
"time": "2017-11-07T14:24:50+00:00"
"time": "2017-11-14T15:08:13+00:00"
},
{
"name": "laravel/socialite",
......@@ -2502,16 +2504,16 @@
},
{
"name": "symfony/console",
"version": "v3.3.11",
"version": "v3.3.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "fd684d68f83568d8293564b4971928a2c4bdfc5c"
"reference": "099302cc53e57cbb7414fd9f3ace40e5e2767c0b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/fd684d68f83568d8293564b4971928a2c4bdfc5c",
"reference": "fd684d68f83568d8293564b4971928a2c4bdfc5c",
"url": "https://api.github.com/repos/symfony/console/zipball/099302cc53e57cbb7414fd9f3ace40e5e2767c0b",
"reference": "099302cc53e57cbb7414fd9f3ace40e5e2767c0b",
"shasum": ""
},
"require": {
......@@ -2566,11 +2568,11 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2017-11-07T14:16:22+00:00"
"time": "2017-11-12T16:53:41+00:00"
},
{
"name": "symfony/css-selector",
"version": "v3.3.11",
"version": "v3.3.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
......@@ -2623,7 +2625,7 @@
},
{
"name": "symfony/debug",
"version": "v3.3.11",
"version": "v3.3.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
......@@ -2679,7 +2681,7 @@
},
{
"name": "symfony/event-dispatcher",
"version": "v3.3.11",
"version": "v3.3.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
......@@ -2742,7 +2744,7 @@
},
{
"name": "symfony/finder",
"version": "v3.3.11",
"version": "v3.3.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
......@@ -2791,16 +2793,16 @@
},
{
"name": "symfony/http-foundation",
"version": "v3.3.11",
"version": "v3.3.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "873ccdf8c1cae20da0184862820c434e20fdc8ce"
"reference": "5943f0f19817a7e05992d20a90729b0dc93faf36"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/873ccdf8c1cae20da0184862820c434e20fdc8ce",
"reference": "873ccdf8c1cae20da0184862820c434e20fdc8ce",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/5943f0f19817a7e05992d20a90729b0dc93faf36",
"reference": "5943f0f19817a7e05992d20a90729b0dc93faf36",
"shasum": ""
},
"require": {
......@@ -2840,20 +2842,20 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
"time": "2017-11-05T19:07:00+00:00"
"time": "2017-11-13T18:13:16+00:00"
},
{
"name": "symfony/http-kernel",
"version": "v3.3.11",
"version": "v3.3.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
"reference": "f38c96b8d88a37b4f6bc8ae46a48b018d4894dd0"
"reference": "371ed63691c1ee8749613a6b48cf0e0cfa2b01e7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/f38c96b8d88a37b4f6bc8ae46a48b018d4894dd0",
"reference": "f38c96b8d88a37b4f6bc8ae46a48b018d4894dd0",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/371ed63691c1ee8749613a6b48cf0e0cfa2b01e7",
"reference": "371ed63691c1ee8749613a6b48cf0e0cfa2b01e7",
"shasum": ""
},
"require": {
......@@ -2926,7 +2928,7 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
"time": "2017-11-10T20:08:13+00:00"
"time": "2017-11-13T19:37:21+00:00"
},
{
"name": "symfony/polyfill-mbstring",
......@@ -3097,16 +3099,16 @@
},
{
"name": "symfony/process",
"version": "v3.3.11",
"version": "v3.3.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "e14bb64d7559e6923fb13ee3b3d8fa763a2c0930"
"reference": "a56a3989fb762d7b19a0cf8e7693ee99a6ffb78d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/e14bb64d7559e6923fb13ee3b3d8fa763a2c0930",
"reference": "e14bb64d7559e6923fb13ee3b3d8fa763a2c0930",
"url": "https://api.github.com/repos/symfony/process/zipball/a56a3989fb762d7b19a0cf8e7693ee99a6ffb78d",
"reference": "a56a3989fb762d7b19a0cf8e7693ee99a6ffb78d",
"shasum": ""
},
"require": {
......@@ -3142,11 +3144,11 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2017-11-05T15:47:03+00:00"
"time": "2017-11-13T15:31:11+00:00"
},
{
"name": "symfony/routing",
"version": "v3.3.11",
"version": "v3.3.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
......@@ -3224,7 +3226,7 @@
},
{
"name": "symfony/translation",
"version": "v3.3.11",
"version": "v3.3.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
......@@ -3289,7 +3291,7 @@
},
{
"name": "symfony/var-dumper",
"version": "v3.3.11",
"version": "v3.3.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
......@@ -3655,6 +3657,39 @@
],
"time": "2017-09-18T13:32:46+00:00"
},
{
"name": "bvipul/generator",
"version": "0.9",
"source": {
"type": "git",
"url": "https://github.com/bvipul/generator.git",
"reference": "c72ff9d734c353e06b46c3248d7797aacbb5cc31"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bvipul/generator/zipball/c72ff9d734c353e06b46c3248d7797aacbb5cc31",
"reference": "c72ff9d734c353e06b46c3248d7797aacbb5cc31",
"shasum": ""
},
"type": "package",
"autoload": {
"psr-4": {
"Bvipul\\Generator\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Vipul Basapati",
"email": "basapativipulkumar@gmail.com"
}
],
"description": "To create a whole module with all related files like model, controller, repository, routes, views etc with a simple GUI.",
"time": "2017-11-14T15:50:43+00:00"
},
{
"name": "doctrine/instantiator",
"version": "1.1.0",
......@@ -5348,7 +5383,7 @@
},
{
"name": "symfony/dom-crawler",
"version": "v3.3.11",
"version": "v3.3.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
......
......@@ -201,6 +201,7 @@ return [
App\Providers\MacroServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
Bvipul\Generator\Provider\CrudGeneratorServiceProvider::class
],
/*
......
<?php
return [
// After App\Http\Controllers
// Default : Backend
'controller_namespace' => 'Backend',
// After App\Http\Requests
// Default : Backend
'request_namespace' => 'Backend',
// After App\Repositories
// Default : Backend
'repository_namespace'=> 'Backend',
// views folder after resources/views
// Default : backend
'views_folder' => 'backend',
];
\ No newline at end of file
<?php
return [
'table' => 'modules',
];
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateMenusTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('menus', function (Blueprint $table) {
$table->increments('id');
$table->enum('type', ['backend', 'frontend']);
$table->string('name', 191);
$table->text('items', 65535)->nullable();
$table->integer('created_by')->unsigned();
$table->integer('updated_by')->unsigned()->nullable();
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('menus');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateModulesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('modules', function (Blueprint $table) {
$table->increments('id');
$table->string('view_permission_id', 191);
$table->string('name', 191);
$table->string('url', 191)->nullable()->comment('view_route');
$table->integer('created_by')->unsigned();
$table->integer('updated_by')->unsigned()->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('modules');
}
}
......@@ -26,8 +26,6 @@ class DatabaseSeeder extends Seeder
$this->call(CountryTableSeeder::class);
$this->call(StateTableSeeder::class);
$this->call(CmsPagesTableSeeder::class);
$this->call(ModulesTableSeeder::class);
$this->call(MenuTableSeeder::class);
Model::reguard();
}
......
<?php
use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class MenuTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table(config('access.menus_table'))->truncate();
$menu = [
'id' => 1,
'type' => 'backend',
'name' => 'Backend Sidebar Menu',
'items' => '[{"view_permission_id":"view-access-management","open_in_new_tab":0,"url_type":"route","url":"","name":"Access Management","id":11,"content":"Access Management","children":[{"view_permission_id":"view-user-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.user.index","name":"User Management","id":12,"content":"User Management"},{"view_permission_id":"view-role-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.role.index","name":"Role Management","id":13,"content":"Role Management"},{"view_permission_id":"view-permission-management","open_in_new_tab":0,"url_type":"route","url":"admin.access.permission.index","name":"Permission Management","id":14,"content":"Permission Management"}]},{"id":1,"name":"Module","url":"admin.modules.index","url_type":"route","open_in_new_tab":0,"view_permission_id":"view-module","content":"Module"},{"view_permission_id":"view-menu","open_in_new_tab":0,"url_type":"route","url":"admin.menus.index","name":"Menus","id":3,"content":"Menus"},{"id":2,"name":"CMS Pages","url":"admin.cmspages.index","url_type":"route","open_in_new_tab":0,"view_permission_id":"view-cms-pages","content":"CMS Pages"},{"view_permission_id":"view-email-template","open_in_new_tab":0,"url_type":"route","url":"admin.emailtemplates.index","name":"Email Templates","id":8,"content":"Email Templates"},{"view_permission_id":"edit-settings","open_in_new_tab":0,"url_type":"route","url":"admin.settings.edit?id=1","name":"Settings","id":9,"content":"Settings"},{"view_permission_id":"view-blog","open_in_new_tab":0,"url_type":"route","url":"","name":"Blog Management","id":15,"content":"Blog Management","children":[{"view_permission_id":"view-blog-category","open_in_new_tab":0,"url_type":"route","url":"admin.blogcategories.index","name":"Blog Category Management","id":16,"content":"Blog Category Management"},{"view_permission_id":"view-blog-tag","open_in_new_tab":0,"url_type":"route","url":"admin.blogtags.index","name":"Blog Tag Management","id":17,"content":"Blog Tag Management"},{"view_permission_id":"view-blog","open_in_new_tab":0,"url_type":"route","url":"admin.blogs.index","name":"Blog Management","id":18,"content":"Blog Management"}]},{"view_permission_id":"view-faq","open_in_new_tab":0,"url_type":"route","url":"admin.faqs.index","name":"Faq Management","id":19,"content":"Faq Management"}]',
'created_by' => 1,
'created_at' => Carbon::now(),
];
DB::table(config('access.menus_table'))->insert($menu);
}
}
<?php
use Carbon\Carbon;
use Database\TruncateTable;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class ModulesTableSeeder extends Seeder
{
use TruncateTable;
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->truncate(config('module.table'));
$modules = [
[
'name' => trans('menus.backend.access.title'),
'url' => null,
'view_permission_id' => 'view-access-management',
'created_by' => 1,
'created_at' => Carbon::now(),
],
[
'name' => trans('labels.backend.access.users.management'),
'url' => 'admin.access.user.index',
'view_permission_id' => 'view-user-management',
'created_by' => 1,
'created_at' => Carbon::now(),
],
[
'name' => trans('labels.backend.access.roles.management'),
'url' => 'admin.access.role.index',
'view_permission_id' => 'view-role-management',
'created_by' => 1,
'created_at' => Carbon::now(),
],
[
'name' => trans('labels.backend.access.permissions.management'),
'url' => 'admin.access.permission.index',
'view_permission_id' => 'view-permission-management',
'created_by' => 1,
'created_at' => Carbon::now(),
],
[
'name' => trans('labels.backend.menus.title'),
'url' => 'admin.menus.index',
'view_permission_id' => 'view-menu',
'created_by' => 1,
'created_at' => Carbon::now(),
],
[
'name' => trans('labels.backend.modules.title'),
'url' => 'admin.modules.index',
'view_permission_id' => 'view-module',
'created_by' => 1,
'created_at' => Carbon::now(),
],
[
'name' => trans('labels.backend.cmspages.title'),
'url' => 'admin.cmspages.index',
'view_permission_id' => 'view-cms-pages',
'created_by' => 1,
'created_at' => Carbon::now(),
],
[
'name' => trans('labels.backend.emailtemplates.title'),
'url' => 'admin.emailtemplates.index',
'view_permission_id' => 'view-email-template',
'created_by' => 1,
'created_at' => Carbon::now(),
],
[
'name' => trans('labels.backend.settings.title'),
'url' => 'admin.settings.edit',
'view_permission_id' => 'edit-settings',
'created_by' => 1,
'created_at' => Carbon::now(),
],
[
'name' => trans('menus.backend.blog.management'),
'url' => null,
'view_permission_id' => 'view-blog',
'created_by' => 1,
'created_at' => Carbon::now(),
],
[
'name' => trans('menus.backend.blogcategories.management'),
'url' => 'admin.blogcategories.index',
'view_permission_id' => 'view-blog-category',
'created_by' => 1,
'created_at' => Carbon::now(),
],
[
'name' => trans('menus.backend.blogtags.management'),
'url' => 'admin.blogtags.index',
'view_permission_id' => 'view-blog-tag',
'created_by' => 1,
'created_at' => Carbon::now(),
],
[
'name' => trans('menus.backend.blog.management'),
'url' => 'admin.blogs.index',
'view_permission_id' => 'view-blog',
'created_by' => 1,
'created_at' => Carbon::now(),
],
[
'name' => trans('menus.backend.faqs.management'),
'url' => 'admin.faqs.index',
'view_permission_id' => 'view-faq',
'created_by' => 1,
'created_at' => Carbon::now(),
],
];
DB::table(config('module.table'))->insert($modules);
}
}
......@@ -50,14 +50,6 @@
</ul>
</li>
@endauth
@role(1)
<li class="{{ active_class(Active::checkUriPattern('admin/modules*')) }}">
<a href="{{ route('admin.modules.index') }}">
<i class="fa fa-file-text"></i>
<span>{{ trans('labels.backend.modules.title') }}</span>
</a>
</li>
@endauth
@permission('view-cms-pages')
<li class="{{ active_class(Active::checkUriPattern('admin/cmspages*')) }}">
<a href="{{ route('admin.cmspages.index') }}">
......@@ -82,6 +74,12 @@
</a>
</li>
@endauth
<li class="{{ active_class(Active::checkUriPattern('admin/modules*')) }}">
<a href="{{ route('admin.modules.index') }}">
<i class="fa fa-gear"></i>
<span>{{ trans('generator::menus.modules.management') }}</span>
</a>
</li>
@permission('view-blog')
<li class="{{ active_class(Active::checkUriPattern('admin/blog*')) }} treeview">
<a href="#">
......@@ -121,14 +119,6 @@
</a>
</li>
@endauth
@permission('view-menu')
<li class="{{ active_class(Active::checkUriPattern('admin/menus*')) }}">
<a href="{{ route('admin.menus.index')}}">
<i class="fa fa-align-right"></i>
<span>{{ trans('labels.backend.menus.management') }}</span>
</a>
</li>
@endauth
</li>
@endauth
......
......@@ -47,7 +47,7 @@
<div class="wrapper">
@include('backend.includes.header')
@include('backend.includes.sidebar-dynamic')
@include('backend.includes.sidebar')
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
......
{{ Form::open(['class' => 'form-horizontal hidden', 'role' => 'form', 'method' => 'post', 'id' => 'menu-add-custom-url']) }}
<div class="form-group">
{{ Form::label('name', trans('labels.backend.menus.field.name'), ['class' => 'col-lg-3 col-md-3 col-sm-3 control-label required']) }}
<div class="col-lg-9 col-md-9 col-sm-9">
{{ Form::text('name', null, ['class' => 'form-control box-size mi-name', 'id' => '', 'placeholder' => trans('labels.backend.menus.field.name'), 'required' => 'required']) }}
</div>
</div>
<div class="form-group">
{{ Form::label('url', trans('labels.backend.menus.field.url'), ['class' => 'col-lg-3 col-md-3 col-sm-3 control-label']) }}
<div class="col-lg-9 col-md-9 col-sm-9">
{{ Form::text('url', null, ['class' => 'form-control box-size mi-url', 'placeholder' => trans('labels.backend.menus.field.url')]) }}
</div>
</div>
<div class="form-group">
{{ Form::label('url', trans('labels.backend.menus.field.url_type'), ['class' => 'col-lg-3 col-md-3 col-sm-3 control-label']) }}
<div class="col-lg-9 col-md-9 col-sm-9 ">
<div class="radio">
<label class="radio-inline">{{ Form::radio('url_type', 'route', null, ['class' => 'mi-url_type_route']) }} {{ trans('labels.backend.menus.field.url_types.route') }}</label>
<label class="radio-inline">{{ Form::radio('url_type', 'static', true, ['class' => 'mi-url_type_static']) }} {{ trans('labels.backend.menus.field.url_types.static') }}</label>
</div>
<div class="checkbox">
{{ Form::hidden('open_in_new_tab', 0) }}
<label>
{{ Form::checkbox('open_in_new_tab', 1, false, ['class' => 'mi-open_in_new_tab']) }} {{ trans('labels.backend.menus.field.open_in_new_tab') }}
</label>
</div>
</div>
</div>
<div class="form-group">
{{ Form::label('icon', trans('labels.backend.menus.field.icon'), ['class' => 'col-lg-3 col-md-3 col-sm-3 control-label', 'title' => trans('labels.backend.menus.field.icon_title')]) }}
<div class="col-lg-9 col-md-9 col-sm-9">
{{ Form::text('icon', null, ['class' => 'form-control box-size mi-icon', 'placeholder' => trans('labels.backend.menus.field.icon_title')]) }}
</div>
</div>
<div class="form-group view-permission-block">
{{ Form::label('view_permission_id', trans('labels.backend.menus.field.view_permission_id'), ['class' => 'col-lg-3 col-md-3 col-sm-3 control-label']) }}
<div class="col-lg-9 col-md-9 col-sm-9">
{{ Form::text('view_permission_id', null, ['class' => 'form-control box-size mi-view_permission_id', 'placeholder' => trans('labels.backend.menus.field.view_permission_id')]) }}
</div>
</div>
{{ Form::hidden('id', null, ['class' => 'mi-id']) }}
<div class="box-body">
<div class="form-group">
<div class="edit-form-btn">
{{ Form::reset(trans('buttons.general.cancel'), ['class' => 'btn btn-default btn-md', 'data-dismiss' => 'modal']) }}
{{ Form::submit(trans('buttons.general.save'), ['class' => 'btn btn-primary btn-md']) }}
<div class="clearfix"></div>
</div>
</div>
</div>
{{ Form::close() }}
@extends ('backend.layouts.app')
@section ('title', trans('labels.backend.menus.management') . ' | ' . trans('labels.backend.menus.create'))
@section('page-header')
<h1>
{{ trans('labels.backend.menus.management') }}
<small>{{ trans('labels.backend.menus.create') }}</small>
</h1>
@endsection
@section('content')
{{ Form::open(['route' => 'admin.menus.store', 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'post', 'id' => 'create-menu', 'files' => false]) }}
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('labels.backend.menus.create') }}</h3>
<div class="box-tools pull-right">
@include('backend.menus.partials.header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
{{-- Including Form blade file --}}
<div class="box-body">
<div class="form-group">
@include("backend.menus.form")
<div class="edit-form-btn">
{{ link_to_route('admin.menus.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }}
{{ Form::submit(trans('buttons.general.crud.create'), ['class' => 'btn btn-primary btn-md']) }}
<div class="clearfix"></div>
</div>
</div>
</div><!--box-->
</div>
{{ Form::close() }}
@include("backend.menus.partials.modal")
@endsection
@extends ('backend.layouts.app')
@section ('title', trans('labels.backend.menus.management') . ' | ' . trans('labels.backend.menus.edit'))
@section('page-header')
<h1>
{{ trans('labels.backend.menus.management') }}
<small>{{ trans('labels.backend.menus.edit') }}</small>
</h1>
@endsection
@section('content')
{{ Form::model($menu, ['route' => ['admin.menus.update', $menu], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-role', 'files' => true]) }}
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('labels.backend.menus.edit') }}</h3>
<div class="box-tools pull-right">
@include('backend.menus.partials.header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
{{-- Including Form blade file --}}
<div class="box-body">
<div class="form-group">
@include("backend.menus.form")
<div class="edit-form-btn">
{{ link_to_route('admin.menus.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }}
{{ Form::submit(trans('buttons.general.crud.update'), ['class' => 'btn btn-primary btn-md']) }}
<div class="clearfix"></div>
</div>
</div>
</div><!--box-->
</div>
{{ Form::close() }}
@include("backend.menus.partials.modal")
@endsection
\ No newline at end of file
<div class="box-body">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="form-group">
{{ Form::label('categories', trans('labels.backend.menus.field.type'), ['class' => 'col-lg-4 col-md-4 col-sm-4 control-label required']) }}
<div class="col-lg-8 col-md-8 col-sm-8">
{{ Form::select('type', $types, null, ['class' => 'form-control tags box-size', 'required' => 'required']) }}
</div>
</div>
</div>
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="form-group">
{{ Form::label('name', trans('labels.backend.menus.field.name'), ['class' => 'col-lg-2 col-md-2 col-sm-2 control-label required']) }}
<div class="col-lg-10 col-md-10 col-sm-10">
{{ Form::text('name', null, ['class' => 'form-control box-size', 'placeholder' => trans('labels.backend.menus.field.name'), 'required' => 'required']) }}
</div>
</div>
</div>
</div>
</div>
<hr/>
<div class="row ">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="col-lg-4 col-md-4 col-sm-4 ">
<div class="row">
<div class="col-lg-12">
@foreach ($modules as $module)
<div class="row modules-list-item">
<div class="col-lg-10">
<span >{{ $module->name }}&nbsp;&nbsp;</span>
</div>
<div class="col-lg-2">
<a href="javascript:void(0);"><i class="fa fa-plus add-module-to-menu" data-id="{{ $module->id }}" data-name="{{ $module->name }}" data-url="{{ $module->url }}" data-url_type="route" data-open_in_new_tab="0" data-view_permission_id="{{ $module->view_permission_id }}" ></i></a>
</div>
</div>
@endforeach
<br/>
<button type="button" class="btn btn-info show-modal" data-form="_add_custom_url_form" data-header="Add Custom URL"><i class="fa fa-plus" ></i>&nbsp;&nbsp;Add Custom URL</button>
</div>
</div>
</div>
<div class="col-lg-8 col-md-8 col-sm-8 ">
{{ Form::hidden('items', empty($menu->items) ? '{}' : $menu->items, ['class' => 'menu-items-field']) }}
<div class="well">
<div id="menu-items" class="dd">
</div>
</div>
</div>
</div>
</div>
</div>
@section("after-styles")
{!! Html::style('css/nestable2/jquery.nestable.css') !!}
@endsection
@section("after-scripts")
{{ Html::script('js/nestable2/jquery.nestable.js') }}
<script type="text/javascript">
//FinBuilders.Blog.init();
var formName = '_add_custom_url_form';
var lastId = null;
$('#menu-items').nestable({
callback: function(l, e){
$(".menu-items-field").val(JSON.stringify($(l).nestable('serialise')));
},
json: $(".menu-items-field").val(),
includeContent:true,
scroll: false,
maxDepth: 10
});
$(".show-modal").click(function(){
$("#showMenuModal").find(".modal-dialog .modal-content .modal-header .modal-title").html($(this).attr("data-header"));
formName = $(this).attr("data-form");
$("#showMenuModal").modal("show");
setTimeout(function() {
$(document).find("#showMenuModal .view-permission-block").remove();
$(document).find("#menu-add-custom-url").removeClass("hidden");
}, 500);
});
$("#showMenuModal").on('show.bs.modal', function () {
$.get("{{ route('admin.menus.getform') }}/" + formName, function(data, status){
if(status == "success") {
$("#showMenuModal").find(".modal-dialog .modal-content .modal-body").html(data);
}
else {
$("#showMenuModal").find(".modal-dialog .modal-content .modal-body").html("Something went wrong! Please try again later.");
}
});
});
var getNewId = function(str) {
var arr = str.match(/"id":[0-9]+/gi);
if(arr) {
$.each(arr, function(index, item) {
arr[index] = parseInt(item.replace('"id":', ''));
});
return Math.max.apply(Math, arr) + 1;
}
return 1;
}
var addMenuItem = function(obj) {
$('#menu-items').nestable('add', {
"id": getNewId($(".menu-items-field").val()),
"content": obj.name,
"name": obj.name,
"url": obj.url,
"url_type" : obj.url_type,
"open_in_new_tab": obj.open_in_new_tab,
"icon": obj.icon,
"view_permission_id": obj.view_permission_id
});
$(".menu-items-field").val(JSON.stringify($('#menu-items').nestable('serialise')));
}
var editMenuItem = function(obj) {
var newObject = {
"id": obj.id,
"content": obj.name,
"name": obj.name,
"url": obj.url,
"url_type": obj.url_type,
"open_in_new_tab": obj.open_in_new_tab,
"icon": obj.icon,
"view_permission_id": obj.view_permission_id
};
var menuItems = $("#menu-items").nestable('serialise');
var itemData;
$.each(menuItems, function(index, item){
itemData = findItemById(item, id);
if(itemData) { return false; }
});
if(itemData.children) {
newObject.children = itemData.children;
}
$('#menu-items').nestable('replace', newObject);
$(".menu-items-field").val(JSON.stringify($('#menu-items').nestable('serialise')));
}
$(document).on("submit", "#menu-add-custom-url", function(e){
e.preventDefault();
var formData = $(this).serializeArray().reduce(function(obj, item) {
obj[item.name] = item.value;
return obj;
}, {});
if(formData.name.length > 0) {
if(formData.id.length > 0) {
editMenuItem(formData);
} else {
addMenuItem(formData);
}
$("#showMenuModal").modal("hide");
}
});
$(document).on("click", ".add-module-to-menu", function(){
var dataObj = {
id: $(this).attr("data-id"),
name: $(this).attr("data-name"),
url: $(this).attr("data-url"),
url_type: $(this).attr("data-url_type"),
open_in_new_tab: $(this).attr("data-open_in_new_tab"),
view_permission_id: $(this).attr("data-view_permission_id"),
}
addMenuItem(dataObj);
});
var findItemById = function(item, id) {
if(item.id == id) {
return item;
}
var found = false;
var foundItem;
if(item.children){
$.each(item.children, function(index, childItem){
foundItem = findItemById(childItem, id);
if(foundItem)
{
console.log(foundItem);
found = true;
return false;
}
});
}
if(found)
{
return foundItem;
}
return null;
};
$(document).ready(function(){
$(document).on("click", ".edit-menu-item", function() {
id = $(this).parents(".dd-item").first().attr("data-id");
$("#showMenuModal").modal("show");
var menuItems = $("#menu-items").nestable('serialise');
var itemData;
$.each(menuItems, function(index, item){
itemData = findItemById(item, id);
//console.log(itemData);
if(itemData) { return false; }
});
if(itemData.id != undefined && itemData.id == id)
{
setTimeout(function() {
$("#showMenuModal").find(".modal-dialog .modal-content .modal-header .modal-title").html("Edit: "+itemData.name);
$(document).find("#showMenuModal .mi-id").val(itemData.id);
$(document).find("#showMenuModal .mi-name").val(itemData.name);
$(document).find("#showMenuModal .mi-url").val(itemData.url);
$(document).find("#showMenuModal .mi-url_type_"+itemData.url_type).prop("checked", true);
if(itemData.open_in_new_tab == 1) {
$(document).find("#showMenuModal .mi-open_in_new_tab").prop("checked", true);
}
$(document).find("#showMenuModal .mi-icon").val(itemData.icon);
if(itemData.view_permission_id) {
$(document).find("#showMenuModal .mi-view_permission_id").val(itemData.view_permission_id);
} else {
$(document).find("#showMenuModal .view-permission-block").remove();
}
$(document).find("#menu-add-custom-url").removeClass("hidden");
}, 500 );
return;
}
});
$(document).on("click", ".remove-menu-item", function() {
$("#menu-items").nestable('remove', $(this).parents(".dd-item").first().attr("data-id"));
$(".menu-items-field").val(JSON.stringify($("#menu-items").nestable('serialise')));
});
});
</script>
@endsection
@extends ('backend.layouts.app')
@section ('title', trans('labels.backend.menus.management'))
@section('page-header')
<h1>{{ trans('labels.backend.menus.management') }}</h1>
@endsection
@section('content')
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('labels.backend.menus.management') }}</h3>
<div class="box-tools pull-right">
@include('backend.menus.partials.header-buttons')
</div>
</div><!-- /.box-header -->
<div class="box-body">
<div class="table-responsive data-table-wrapper">
<table id="menus-table" class="table table-condensed table-hover table-bordered">
<thead>
<tr>
<th>{{ trans('labels.backend.menus.table.name') }}</th>
<th>{{ trans('labels.backend.menus.table.type') }}</th>
<th>{{ trans('labels.backend.menus.table.createdat') }}</th>
<th>{{ trans('labels.general.actions') }}</th>
</tr>
</thead>
<thead class="transparent-bg">
<tr>
<th>
{!! Form::text('first_name', null, ["class" => "search-input-text form-control", "data-column" => 0, "placeholder" => trans('labels.backend.menus.table.name')]) !!}
<a class="reset-data" href="javascript:void(0)"><i class="fa fa-times"></i></a>
</th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
</table>
</div><!--table-responsive-->
</div><!-- /.box-body -->
</div><!--box-->
<!--<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('history.backend.recent_history') }}</h3>
<div class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div><!-- /.box tools -->
</div><!-- /.box-header -->
<div class="box-body">
{{-- {!! history()->renderType('Blog') !!} --}}
</div><!-- /.box-body -->
</div><!--box box-success-->
@endsection
@section('after-scripts')
{{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }}
<script>
$(function() {
var dataTable = $('#menus-table').dataTable({
processing: true,
serverSide: true,
ajax: {
url: '{{ route("admin.menus.get") }}',
type: 'post'
},
columns: [
{data: 'name', name: '{{config('access.menus_table')}}.name'},
{data: 'type', name: '{{config('access.menus_table')}}.type'},
{data: 'created_at', name: '{{config('access.menus_table')}}.created_at'},
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[3, "asc"]],
searchDelay: 500,
dom: 'lBfrtip',
buttons: {
buttons: [
{ extend: 'copy', className: 'copyButton', exportOptions: {columns: [ 0, 1, 2 ] }},
{ extend: 'csv', className: 'csvButton', exportOptions: {columns: [ 0, 1, 2 ] }},
{ extend: 'excel', className: 'excelButton', exportOptions: {columns: [ 0, 1, 2 ] }},
{ extend: 'pdf', className: 'pdfButton', exportOptions: {columns: [ 0, 1, 2 ] }},
{ extend: 'print', className: 'printButton', exportOptions: {columns: [ 0, 1, 2 ] }}
]
}
});
FinBuilders.DataTableSearch.init(dataTable);
});
</script>
@endsection
\ No newline at end of file
<div id="showMenuModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<p>Something went wrong! Please try again later.</p>
</div>
{{-- <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div> --}}
</div>
</div>
</div>
\ No newline at end of file
<div class="box-body">
<!-- Module Name -->
<div class="form-group">
{{ Form::label('name', trans('labels.backend.modules.form.name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog', 'required' => 'required']) }}
</div><!--col-lg-10-->
</div>
{{-- <!-- Module Url -->
<div class="form-group">
{{ Form::label('url', trans('labels.backend.modules.form.url'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('url', null, ['class' => 'form-control box-size', 'placeholder' => '', 'required' => 'required']) }}
</div><!--col-lg-10-->
</div>
<!-- Module View Permission -->
<div class="form-group">
{{ Form::label('view_permission_id', trans('labels.backend.modules.form.view_permission_id'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('view_permission_id', null, ['class' => 'form-control box-size view-permission', 'placeholder' => '', 'required' => 'required']) }}
<div class="permission-messages">
</div>
</div><!--col-lg-10-->
</div> --}}
<!-- Directory -->
<div class="form-group">
{{ Form::label('directory_name', trans('labels.backend.modules.form.directory_name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('directory_name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog', 'required' => true]) }}
</div><!--col-lg-10-->
</div>
<!-- End Directory -->
{{-- <div class="form-group">
{{ Form::label('model_namespace', trans('labels.backend.modules.form.namespace'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
<div class="input-group box-size">
<span class="input-group-addon">{{ $model_namespace }}</span>
{{ Form::text('model_namespace', $model_directory, ['class' => 'form-control', 'placeholder' => '']) }}
</div>
</div><!--col-lg-10-->
</div><!--form control--> --}}
<!-- Model Name -->
<div class="form-group">
{{ Form::label('model_name', trans('labels.backend.modules.form.model_name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('model_name', null, ['class' => 'form-control box-size only-text', 'placeholder' => 'e.g., Blog']) }}
<div class="model-messages"></div>
</div>
</div>
<!-- End Model Name -->
<!-- Table Name -->
<div class="form-group">
{{ Form::label('table_name', trans('labels.backend.modules.form.table_name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('table_name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog']) }}
<div class="table-messages"></div>
</div><!--col-lg-10-->
</div>
<!-- End Table Name -->
<!-- Crud Operations Create/Edit/Delete to be added to the field (Read operation is given by default)-->
<div class="form-group">
{{ Form::label('operations', 'Operations', ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-8">
<label class="control control--checkbox">
<!-- For Create Operation of CRUD -->
{{ Form::checkbox('model_create', '1', false) }}Create
<div class="control__indicator"></div>
</label>
<label class="control control--checkbox">
<!-- For Edit Operation of CRUD -->
{{ Form::checkbox('model_edit', '1', false) }}Edit
<div class="control__indicator"></div>
</label>
<label class="control control--checkbox">
<!-- For Delete Operation of CRUD -->
{{ Form::checkbox('model_delete', '1', false) }}Delete
<div class="control__indicator"></div>
</label>
</div>
</div>
<!-- End Crud Operations -->
<!-- Model -->
{{-- <div class="form-group">
<div class="col-lg-8 col-lg-offset-2 box-size">
<div class="panel panel-default box-size">
<div class="panel-heading">
<div class="control-group" style="display:inline">
<label class="control control--checkbox">
{{ Form::checkbox('model', 1, false) }}Model
<div class="control__indicator"></div>
</label>
</div>
</div>
<div class="panel-body hidden model">
<div class="form-group">
{{ Form::label('model_namespace', trans('labels.backend.modules.form.namespace'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
<div class="input-group box-size">
<span class="input-group-addon">{{ $model_namespace }}</span>
{{ Form::text('model_namespace', $model_directory, ['class' => 'form-control', 'placeholder' => '']) }}
</div>
</div><!--col-lg-10-->
</div><!--form control-->
<div class="form-group">
{{ Form::label('model_name', trans('labels.backend.modules.form.model_name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('model_name', null, ['class' => 'form-control box-size only-text', 'placeholder' => 'e.g., Blog']) }}
</div>
</div>
<div class="form-group">
{{ Form::label('table_name', trans('labels.backend.modules.form.table_name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('table_name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog']) }}
</div><!--col-lg-10-->
</div>
<!-- Crud Operations Create/Edit/Delete to be added to the field (Read operation is given by default)-->
<div class="form-group">
<div class="col-lg-2">
{{ Form::label('operations', 'Operations', ['class' => 'control-label']) }}
</div>
<div class="col-lg-8">
<label class="control control--checkbox">
<!-- For Create Operation of CRUD -->
{{ Form::checkbox('model_create', '1', false) }}Create
<div class="control__indicator"></div>
</label>
<label class="control control--checkbox">
<!-- For Edit Operation of CRUD -->
{{ Form::checkbox('model_edit', '1', false) }}Edit
<div class="control__indicator"></div>
</label>
<label class="control control--checkbox">
<!-- For Delete Operation of CRUD -->
{{ Form::checkbox('model_delete', '1', false) }}Delete
<div class="control__indicator"></div>
</label>
</div>
</div>
<div class="table-messages"></div>
<div class="model-messages"></div>
</div>
</div>
</div>
</div> --}}
{{-- <!-- Controller -->
<div class="form-group">
<div class="col-lg-8 col-lg-offset-2 box-size">
<div class="panel panel-default box-size">
<div class="panel-heading">
<div class="control-group" style="display:inline">
<label class="control control--checkbox">
{{ Form::checkbox('controller', 1, false) }}Controller
<div class="control__indicator"></div>
</label>
</div>
</div>
<div class="panel-body hidden controller">
<div class="form-group">
{{ Form::label('controller_namespace', trans('labels.backend.modules.form.namespace'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
<div class="input-group box-size">
<span class="input-group-addon">{{ $controller_namespace }}</span>
{{ Form::text('controller_namespace', null, ['class' => 'form-control box-size', 'placeholder' => '']) }}
</div>
</div><!--col-lg-10-->
</div><!--form control-->
<div class="form-group">
{{ Form::label('controller_name', trans('labels.backend.modules.form.controller_name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('controller_name', null, ['class' => 'form-control box-size only-text', 'placeholder' => 'e.g., BlogController', 'pattern' => "[A-Za-z]+" ] ) }}
</div>
</div>
<div class="controller-messages">
</div>
</div>
</div>
</div>
</div> --}}
<!-- Table Controller -->
{{-- <div class="form-group">
<div class="col-lg-8 col-lg-offset-2 box-size">
<div class="panel panel-default box-size">
<div class="panel-heading">
<div class="control-group" style="display:inline">
<label class="control control--checkbox">
{{ Form::checkbox('table_controller', 1, false) }}Table Controller
<div class="control__indicator"></div>
</label>
</div>
</div>
<div class="panel-body hidden table_controller">
<div class="form-group">
{{ Form::label('table_controller_namespace', trans('labels.backend.modules.form.namespace'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
<div class="input-group box-size">
<span class="input-group-addon">{{ $controller_namespace }}</span>
{{ Form::text('table_controller_namespace', null, ['class' => 'form-control box-size required', 'placeholder' => '']) }}
</div>
</div><!--col-lg-10-->
</div><!--form control-->
<div class="form-group">
{{ Form::label('table_controller_name', trans('labels.backend.modules.form.table_controller_name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('table_controller_name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., BlogController']) }}
</div>
</div>
<div class="table_controller-messages">
</div>
</div>
</div>
</div>
</div> --}}
<!-- Migration -->
{{-- <div class="form-group">
<div class="col-lg-8 col-lg-offset-2 box-size">
<div class="panel panel-default box-size">
<div class="panel-heading">
<div class="control-group" style="display:inline">
<label class="control control--checkbox">
{{ Form::checkbox('table', 1, false) }}Migration
<div class="control__indicator"></div>
</label>
</div>
</div>
<div class="panel-body hidden table">
<div class="form-group">
{{ Form::label('table_name', trans('labels.backend.modules.form.table_name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('table_name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog']) }}
</div><!--col-lg-10-->
</div>
<div class="table-messages">
</div>
</div>
</div>
</div>
</div>
<!-- Events & Listeners -->
<div class="form-group">
<div class="col-lg-8 col-lg-offset-2 box-size">
<div class="panel panel-default box-size">
<div class="panel-heading">
<div class="control-group" style="display:inline">
<label class="control control--checkbox">
{{ Form::checkbox('el', 1, false) }}Events & Listeners
<div class="control__indicator"></div>
</label>
</div>
</div>
<div class="panel-body hidden el">
<div class="form-group">
{{ Form::label('event_namespace', 'Namespace', ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
<div class="input-group box-size">
<span class="input-group-addon">{{ $event_namespace }}</span>
{{ Form::text('event_namespace', $event_directory, ['class' => 'form-control box-size', 'placeholder' => '']) }}
</div>
</div><!--col-lg-10-->
</div><!--form control-->
<div class="events-div">
<div class="form-group event clearfix">
{{ Form::label('event[]', trans('labels.backend.modules.form.event'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-6">
{{ Form::text('event[]', null, ['class' => 'form-control box-size', 'placeholder' => trans('labels.backend.modules.form.event'), 'style' => 'width:100%']) }}
</div><!--col-lg-10-->
<a href="#" class="btn btn-danger btn-md remove-field hidden">Remove Event</a>
<a href="#" class="btn btn-primary btn-md add-field">Add Event</a>
</div><!--form control-->
</div>
<div class="el-messages">
</div>
</div>
</div>
</div>
</div> --}}
</div>
@section("after-scripts")
<script type="text/javascript">
//When the DOM is ready to be manipulated
$(document).ready(function(){
model_ns = {!! json_encode($model_namespace) !!};
controller_ns = {!! json_encode($controller_namespace) !!};
event_ns = {!! json_encode($event_namespace) !!};
//If any errors occured
handleAllCheckboxes();
//model checkbox change event
$("input[name=model]").on('change', function(e){
handleCheckBox($(this), $(".model"));
});
//controller checkbox change event
$("input[name=controller]").on('change', function(e){
handleCheckBox($(this), $(".controller"));
});
// //table controller checkbox change event
// $("input[name=table_controller]").on('change', function(e){
// handleCheckBox($(this), $(".table_controller"));
// });
//
// //table checkbox change event
// $("input[name=table]").on('change', function(e){
// handleCheckBox($(this), $(".table"));
// });
//
// //routes checkbox change event
// $("input[name=route]").on('change', function(e){
// handleCheckBox($(this), $(".route"));
// });
//
// //views checkbox change event
// $("input[name=views]").on('change', function(e){
// handleCheckBox($(this), $(".views"));
// throwMessages('warning', 'The files with the same name would be overwritten.', 'views');
// });
//events and listeners checkbox change event
$("input[name=el]").on('change', function(e){
handleCheckBox($(this), $(".el"));
});
//repository checkbox change event
// $("input[name=repository]").on('change', function(e){
// handleCheckBox($(this), $(".repository"));
// });
//Add field in event panel
$(document).on('click', ".add-field", function(e){
e.preventDefault();
clone = $(".event").first().clone();
clone.appendTo(".events-div");
clone.find(".remove-field").removeClass('hidden');
});
//remove field in event panel
$(document).on('click', ".remove-field", function(e){
e.preventDefault();
$(this).parent('div').remove();
});
$(document).on('blur', "input[name=model_name]", function(e){
checkModelExists($(this));
});
$(document).on('blur', "input[name=controller_name]", function(e){
checkControllerExists($(this));
});
// $(document).on('blur', "input[name=table_controller_name]", function(e){
// checkTableControllerExists($(this));
// // });
$(document).on('blur', "input[name=table_name]", function(e){
checkTableExists($(this));
});
// $(document).on('blur', "input[name=repo_name]", function(e){
// checkRepositoryExists($(this));
// });
//
// $(document).on('blur', "input[name='event[]']", function(e){
// checkEventExists($(this));
// });
//
// $(document).on('blur', "input[name=view_permission_id]", function(e){
// checkPermissionExists($(this));
// });
$(document).on('keyup', "input[name=directory_name]", function(e){
handleAllCheckboxes();
//Views Directory value change
$("input[name=views_directory]").val($(this).val().toLowerCase());
});
});
function checkPermissionExists(permission) {
if(permission.val()){
$.post( "{{ route('admin.modules.check.permission') }}", { 'permission' : permission.val()} )
.done( function( data ) {
throwMessages(data.type, data.message, "permission");
});
} else {
throwMessages('error', "Please provide some input.", "permission");
}
}
function checkModelExists(model) {
// if(!$("input[name=directory_name]").val()) {
// throwMessages('warning', 'Please provide directory name and then click [TAB] here.', "model");
// } else {
if(model.val() && $("input[name=model_namespace]").val()) {
path = getPath( model_ns, $("input[name=model_namespace]").val(), model.val());
checkPath(path, 'model');
} else {
throwMessages('error', 'Please provide some input.', "model");
}
// }
}
function checkControllerExists(controller) {
// if(!$("input[name=directory_name]").val()) {
// throwMessages('warning', 'Please provide directory name and then click [TAB] here.', "controller");
// } else {
if(controller.val() && $("input[name=controller_namespace]").val()) {
path = getPath( controller_ns, $("input[name=controller_namespace]").val(), controller.val());
checkPath(path, 'controller');
} else {
throwMessages('error', 'Please provide some input.', "controller");
}
// }
}
function checkTableControllerExists(table_controller) {
if(table_controller.val() && $("input[name=table_controller_namespace]").val()) {
path = getPath( controller_ns, $("input[name=table_controller_namespace]").val(), table_controller.val());
checkPath(path, 'table_controller');
} else {
throwMessages('error', 'Please provide some input.', "table_controller");
}
}
function checkTableExists(table) {
if(table.val()){
$.post( "{{ route('admin.modules.check.table') }}", { 'table' : table.val()} )
.done( function( data ) {
throwMessages(data.type, data.message, "table");
});
} else {
throwMessages('error', "Please provide some input.", "table");
}
}
function checkRepositoryExists(repository) {
// if(!$("input[name=directory_name]").val()) {
// throwMessages('warning', 'Please provide directory name and then click [TAB] here.', "repository");
// } else {
if(repository.val() && $("input[name=repo_namespace]").val()){
path = getPath( repository_ns, $("input[name=repo_namespace]").val(), repository.val());
checkPath(path, 'repository');
} else {
throwMessages('error', 'Please provide some input.', "repository");
}
// }
}
function checkEventExists(event) {
if(event.val() && $("input[name=event_namespace]").val()) {
path = getPath( event_ns, $("input[name=event_namespace]").val(), event.val());
checkPath(path, 'el');
} else {
throwMessages('error', 'Please provide some input.', "el");
}
}
function getPath(ns, namespace, model) {
if(dir = $("input[name=directory_name]").val()) {
return ns + namespace + "\\" + dir + "\\" + model;
} else {
return ns + namespace + "\\" + model;
}
}
function checkPath(path, element) {
$.post( "{{ route('admin.modules.check.namespace') }}", { 'path' : path} )
.done( function( data ) {
throwMessages(data.type, data.message, element);
});
}
function throwMessages(type, message, element) {
appendMessage = '';
switch(type) {
case 'warning' :
appendMessage = "<span class='"+ element +"-warning'><i class='fa fa-exclamation-triangle' aria-hidden='true'></i>&nbsp; "+ message +"</span>";
break;
case 'error' :
appendMessage = "<span class='"+ element +"-error'><i class='fa fa-exclamation-circle' aria-hidden='true'></i>&nbsp; "+ message +"</span>";
break;
case 'success' :
appendMessage = "<span class='"+ element +"-success'><i class='fa fa-check' aria-hidden='true'></i>&nbsp; "+ message +"</span>";
}
$("."+element+"-messages").html(appendMessage);
}
//If any errors occured,
//the panels should automatically be opened
//which were opened before
function handleAllCheckboxes() {
handleCheckBox($("input[name=model]"), $(".model"));
handleCheckBox($("input[name=controller]"), $(".controller"));
handleCheckBox($("input[name=table_controller]"), $(".table_controller"));
handleCheckBox($("input[name=table]"), $(".table"));
handleCheckBox($("input[name=route]"), $(".route"));
handleCheckBox($("input[name=views]"), $(".views"));
handleCheckBox($("input[name=el]"), $(".el"));
handleCheckBox($("input[name=repository]"), $(".repository"));
throwMessages('warning', 'The table name can only contain characters and digits and underscores[_].', 'table');
throwMessages('warning', 'The files with the same name would be overwritten.', 'views');
}
//Handle the checkbox event for that element
function handleCheckBox(checkbox, element){
checkboxValue = checkbox.prop('checked');
// if(!$("input[name=directory_name]").val()) {
// throwMessages('warning', 'Please provide directory name and then click [TAB] here.', checkbox.attr('name'));
// } else {
if($("."+checkbox.attr('name')+"-messages").children().length == 0) {
$("."+checkbox.attr('name')+"-messages").empty();
}
// }
// $(".table-messages").empty();
if(checkboxValue) {
element.removeClass('hidden', 3000);
}
else {
element.addClass('hidden', 3000);
}
//calling required field handler functions
switch (checkbox.attr('name')) {
case 'model' : handleModelRequiredFields(checkboxValue);
break;
case 'controller' : handleControllerRequiredFields(checkboxValue);
break;
case 'table' : handleTableRequiredFields(checkboxValue);
break;
case 'route' : handleRouteRequiredFields(checkboxValue);
break;
case 'repository' : handleRepoRequiredFields(checkboxValue);
break;
case 'el' : handleEventRequiredFields(checkboxValue);
break;
}
}
//Model Required fields if that panel is open
function handleModelRequiredFields(check) {
// $("input[name=model_namespace]").attr('required', check);
$("input[name=model_name]").attr('required', check);
}
//Controller Required fields if that panel is open
function handleControllerRequiredFields(check) {
// $("input[name=controller_namespace]").attr('required', check);
$("input[name=controller_name]").attr('required', check);
}
//Table Required fields if that panel is open
function handleTableRequiredFields(check) {
$("input[name=table_name]").attr('required', check);
}
//Route Required fields if that panel is open
function handleRouteRequiredFields(check) {
$("input[name=route_name]").attr('required', check);
$("input[name=route_controller_name]").attr('required', check);
}
//Repository Required fields if that panel is open
function handleRepoRequiredFields(check) {
$("input[name=repo_namespace]").attr('required', check);
$("input[name=repo_name]").attr('required', check);
}
//Events Required fields if that panel is open
function handleEventRequiredFields(check) {
$("input[name=event_namespace]").attr('required', check);
$("input[name='event[]']").attr('required', check);
}
//For changing namespace
// function changeNamespace(val, ns, element) {
// if(!val) {
// val = ns.replace('/\\\\/g', '');
// } else {
// val = ns + "\\" + val + "\\";
// }
// element.text(val);
// }
//For only characters
$(".only-text").on('keyup', function(e) {
var val = $(this).val();
if (val.match(/[^a-zA-Z]/g)) {
$(this).val(val.replace(/[^a-zA-Z]/g, ''));
}
});
</script>
@endsection
......@@ -18,8 +18,8 @@ trait AttributeClass
public function getActionButtonsAttribute()
{
return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute(editPermission, editRoute).'
'.$this->getDeleteButtonAttribute(deletePermission, deleteRoute).'
'.$this->getEditButtonAttribute("editPermission", "editRoute").'
'.$this->getDeleteButtonAttribute("deletePermission", "deleteRoute").'
</div>';
}
}
<?php
/**
* Routes for : DummyModuleName
*/
Route::group(['namespace' => 'route_namespace', 'prefix' => 'admin', 'as' => 'admin.', 'middleware' => 'admin'], function () {
@startNamespace
Route::group( ['namespace' => 'DummyModel'], function () {
Route::get('dummy_name', 'DummyController@index')->name('dummy_name.index');
@startCreateRoute::get('dummy_name/create', 'DummyController@create')->name('dummy_name.create');
Route::post('dummy_name', 'DummyController@store')->name('dummy_name.store');@endCreate
@startEditRoute::get('dummy_name/{dummy_argument_name}/edit', 'DummyController@edit')->name('dummy_name.edit');
Route::patch('dummy_name/{dummy_argument_name}', 'DummyController@update')->name('dummy_name.update');@endEdit
@startDeleteRoute::delete('dummy_name/{dummy_argument_name}', 'DummyController@destroy')->name('dummy_name.destroy');@endDelete
//For Datatable
Route::post('dummy_name/get', 'DummyTableController')->name('dummy_name.get');
});
@endNamespace@startWithoutNamespace
Route::get('dummy_name', 'DummyController@index')->name('dummy_name.index');
@startCreateRoute::get('dummy_name/create', 'DummyController@create')->name('dummy_name.create');
Route::post('dummy_name', 'DummyController@store')->name('dummy_name.store');@endCreate
@startEditRoute::get('dummy_name/{dummy_argument_name}/edit', 'DummyController@edit')->name('dummy_name.edit');
Route::patch('dummy_name/{dummy_argument_name}', 'DummyController@update')->name('dummy_name.update');@endEdit
@startDeleteRoute::delete('dummy_name/{dummy_argument_name}', 'DummyController@destroy')->name('dummy_name.destroy');@endDelete
//For Datatable
Route::post('dummy_name/get', 'DummyTableController')->name('dummy_name.get');
@endWithoutNamespace
});
\ No newline at end of file
@extends ('backend.layouts.app')
@section ('title', trans('labels.backend.modules.management') . ' | ' . trans('labels.backend.modules.create'))
@section ('title', trans('generator::labels.modules.management') . ' | ' . trans('generator::labels.modules.create'))
@section('page-header')
<h1>
{{ trans('labels.backend.modules.management') }}
<small>{{ trans('labels.backend.modules.create') }}</small>
{{ trans('generator::labels.modules.management') }}
<small>{{ trans('generator::labels.modules.create') }}</small>
</h1>
@endsection
@section('content')
{{ Form::open(['route' => 'admin.modules.store', 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'post', 'id' => 'create-permission', 'files' => true]) }}
{{ Form::open(['route' => 'admin.modules.store', 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'post', 'id' => 'create-module', 'files' => true]) }}
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('labels.backend.modules.create') }}</h3>
<h3 class="box-title">{{ trans('generator::labels.modules.create') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.modules-header-buttons')
@include('generator::partials.modules-header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
{{-- Including Form blade file --}}
<div class="box-body">
<div class="form-group">
@include("backend.modules.form")
@include("generator::form")
<div class="edit-form-btn">
{{ link_to_route('admin.modules.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }}
{{ Form::submit(trans('buttons.general.crud.create'), ['class' => 'btn btn-primary btn-md']) }}
......
@extends ('backend.layouts.app')
@section ('title', trans('labels.backend.modules.management') . ' | ' . trans('labels.backend.modules.edit'))
@section ('title', trans('generator::labels.modules.management') . ' | ' . trans('generator::labels.modules.edit'))
@section('page-header')
<h1>
{{ trans('labels.backend.modules.management') }}
<small>{{ trans('labels.backend.modules.edit') }}</small>
{{ trans('generator::labels.modules.management') }}
<small>{{ trans('generator::labels.modules.edit') }}</small>
</h1>
@endsection
@section('content')
{{ Form::model($module, ['route' => ['admin.modules.update', $module], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-role', 'files' => true]) }}
{{ Form::model($module, ['route' => ['admin.modules.update', $module], 'class' => 'form-horizontal', 'role' => 'form', 'method' => 'PATCH', 'id' => 'edit-module', 'files' => true]) }}
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('labels.backend.modules.edit') }}</h3>
<h3 class="box-title">{{ trans('generator::labels.modules.edit') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.modules-header-buttons')
@include('generator::partials.modules-header-buttons')
</div><!--box-tools pull-right-->
</div><!-- /.box-header -->
......
......@@ -8,7 +8,7 @@
</div>
<!-- Module Name -->
<div class="form-group">
{{ Form::label('name', trans('labels.backend.modules.form.name'), ['class' => 'col-lg-2 control-label required']) }}
{{ Form::label('name', trans('generator::labels.modules.form.name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog', 'required' => 'required']) }}
......@@ -17,7 +17,7 @@
<!-- Directory -->
<div class="form-group">
{{ Form::label('directory_name', trans('labels.backend.modules.form.directory_name'), ['class' => 'col-lg-2 control-label required']) }}
{{ Form::label('directory_name', trans('generator::labels.modules.form.directory_name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('directory_name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog', 'required' => true]) }}
......@@ -27,7 +27,7 @@
<!-- Model Name -->
<div class="form-group">
{{ Form::label('model_name', trans('labels.backend.modules.form.model_name'), ['class' => 'col-lg-2 control-label required']) }}
{{ Form::label('model_name', trans('generator::labels.modules.form.model_name'), ['class' => 'col-lg-2 control-label required']) }}
<div class="col-lg-10">
{{ Form::text('model_name', null, ['class' => 'form-control box-size only-text', 'placeholder' => 'e.g., Blog', 'required' => true]) }}
......@@ -38,7 +38,7 @@
<!-- Table Name -->
<div class="form-group">
{{ Form::label('table_name', trans('labels.backend.modules.form.table_name'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('table_name', trans('generator::labels.modules.form.table_name'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-10">
{{ Form::text('table_name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog']) }}
......@@ -77,10 +77,10 @@
<!-- Events -->
<div class="events-div">
<div class="form-group event clearfix">
{{ Form::label('event[]', trans('labels.backend.modules.form.event'), ['class' => 'col-lg-2 control-label']) }}
{{ Form::label('event[]', trans('generator::labels.modules.form.event'), ['class' => 'col-lg-2 control-label']) }}
<div class="col-lg-6">
{{ Form::text('event[]', null, ['class' => 'form-control box-size', 'placeholder' => trans('labels.backend.modules.form.event'), 'style' => 'width:100%']) }}
{{ Form::text('event[]', null, ['class' => 'form-control box-size', 'placeholder' => trans('generator::labels.modules.form.event'), 'style' => 'width:100%']) }}
</div><!--col-lg-10-->
<a href="#" class="btn btn-danger btn-md remove-field hidden">Remove Event</a>
<a href="#" class="btn btn-primary btn-md add-field">Add Event</a>
......@@ -107,16 +107,9 @@
<!-- Override CheckBox -->
<div class="form-group">
{{-- {{ Form::label('override', trans('validation.attributes.backend.blogtags.is_active'), ['class' => 'col-lg-2 control-label']) }} --}}
<div class="col-lg-2"></div>
<div class="col-lg-10">
<p><strong>Note : </strong> The Files would be overwritten, if already exists. Please look at files (and their respective paths) carefully before creating.</p>
{{-- <div class="control-group">
<label class="control control--checkbox">
{{ Form::checkbox('override', 1, false) }}&nbsp; You want to Override the files to be generated if the files are already present ?
<div class="control__indicator"></div>
</label>
</div><!--col-lg-3--> --}}
</div><!--form control-->
</div>
<!-- end Override Checkbox -->
......
......@@ -12,7 +12,7 @@
<h3 class="box-title">{{ trans('labels.backend.modules.management') }}</h3>
<div class="box-tools pull-right">
@include('backend.includes.partials.modules-header-buttons')
@include('generator::partials.modules-header-buttons')
</div>
</div><!-- /.box-header -->
......
<!--Action Button-->
@if(Active::checkUriPattern('admin/menus'))
@if(Active::checkUriPattern('admin/modules'))
<div class="btn-group">
<button type="button" class="btn btn-warning btn-flat dropdown-toggle" data-toggle="dropdown">Export
<span class="caret"></span>
......@@ -21,10 +21,9 @@
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="{{route('admin.menus.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.menus.all')}}</a></li>
@permission('create-menu')
<li><a href="{{route('admin.menus.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.menus.create')}}</a></li>
@endauth
<li><a href="{{route('admin.modules.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.modules.all')}}</a></li>
<li><a href="{{route('admin.modules.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.modules.create')}}</a></li>
</ul>
</div>
<div class="clearfix"></div>
\ No newline at end of file
<?php
/**
* Menu Management.
*/
Route::group(['namespace' => 'Menu'], function () {
Route::resource('menus', 'MenuController', ['except' => []]);
//For DataTables
Route::post('menus/get', 'MenuTableController')->name('menus.get');
// for Model Forms
Route::get('menus/get-form/{name?}', 'MenuController@getForm')->name('menus.getform');
});
<?php
/**
* Module Generator Routes.
*/
Route::group(['namespace' => 'Module'], function () {
Route::resource('modules', 'ModuleController');
//For DataTables
Route::post('modules/get', 'ModuleTableController')
->name('modules.get');
//Checking namespace exists (file exists)
Route::post('modules/checkNamespace', 'ModuleController@checkNamespace')->name('modules.check.namespace');
//checking table exists
Route::post('modules/checkTable', 'ModuleController@checkTable')->name('modules.check.table');
//checking permission exists
Route::post('modules/checkPermission', 'ModuleController@checkPermission')->name('modules.check.permission');
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment