Commit cb8aab30 authored by Vipul Basapati's avatar Vipul Basapati

Removed Modules and Menu Management from adminpanel and added Module Manager through composer

parent 07ff00a8
<?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
...@@ -15,6 +15,4 @@ require __DIR__.'/Blog_Category.php'; ...@@ -15,6 +15,4 @@ require __DIR__.'/Blog_Category.php';
require __DIR__.'/Blog_Tag.php'; require __DIR__.'/Blog_Tag.php';
require __DIR__.'/Blog_Management.php'; require __DIR__.'/Blog_Management.php';
require __DIR__.'/Faqs.php'; require __DIR__.'/Faqs.php';
require __DIR__.'/Module.php';
require __DIR__.'/Menu.php';
require __DIR__.'/LogViewer.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 [
];
}
}
This diff is collapsed.
<?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')
);
}
}
...@@ -164,64 +164,6 @@ if (!function_exists('escapeSlashes')) { ...@@ -164,64 +164,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')) { if (!function_exists('getMenuItems')) {
/** /**
* Converts items (json string) to array and return array. * Converts items (json string) to array and return array.
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "f0db0856ef828bbe877e49a03cca1cd4", "content-hash": "be8a1de45aed74fa6a71da13ab19b395",
"packages": [ "packages": [
{ {
"name": "arcanedev/log-viewer", "name": "arcanedev/log-viewer",
...@@ -3649,6 +3649,39 @@ ...@@ -3649,6 +3649,39 @@
], ],
"time": "2017-09-18T13:32:46+00:00" "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", "name": "doctrine/instantiator",
"version": "1.0.5", "version": "1.0.5",
......
...@@ -201,6 +201,7 @@ return [ ...@@ -201,6 +201,7 @@ return [
App\Providers\MacroServiceProvider::class, App\Providers\MacroServiceProvider::class,
App\Providers\RouteServiceProvider::class, App\Providers\RouteServiceProvider::class,
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::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 ...@@ -26,8 +26,6 @@ class DatabaseSeeder extends Seeder
$this->call(CountryTableSeeder::class); $this->call(CountryTableSeeder::class);
$this->call(StateTableSeeder::class); $this->call(StateTableSeeder::class);
$this->call(CmsPagesTableSeeder::class); $this->call(CmsPagesTableSeeder::class);
$this->call(ModulesTableSeeder::class);
$this->call(MenuTableSeeder::class);
Model::reguard(); 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 @@ ...@@ -50,14 +50,6 @@
</ul> </ul>
</li> </li>
@endauth @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') @permission('view-cms-pages')
<li class="{{ active_class(Active::checkUriPattern('admin/cmspages*')) }}"> <li class="{{ active_class(Active::checkUriPattern('admin/cmspages*')) }}">
<a href="{{ route('admin.cmspages.index') }}"> <a href="{{ route('admin.cmspages.index') }}">
...@@ -82,6 +74,12 @@ ...@@ -82,6 +74,12 @@
</a> </a>
</li> </li>
@endauth @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') @permission('view-blog')
<li class="{{ active_class(Active::checkUriPattern('admin/blog*')) }} treeview"> <li class="{{ active_class(Active::checkUriPattern('admin/blog*')) }} treeview">
<a href="#"> <a href="#">
...@@ -121,14 +119,6 @@ ...@@ -121,14 +119,6 @@
</a> </a>
</li> </li>
@endauth @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> </li>
@endauth @endauth
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<div class="wrapper"> <div class="wrapper">
@include('backend.includes.header') @include('backend.includes.header')
@include('backend.includes.sidebar-dynamic') @include('backend.includes.sidebar')
<!-- Content Wrapper. Contains page content --> <!-- Content Wrapper. Contains page content -->
<div class="content-wrapper"> <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
This diff is collapsed.
@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
This diff is collapsed.
...@@ -18,8 +18,8 @@ trait AttributeClass ...@@ -18,8 +18,8 @@ trait AttributeClass
public function getActionButtonsAttribute() public function getActionButtonsAttribute()
{ {
return '<div class="btn-group action-btn"> return '<div class="btn-group action-btn">
'.$this->getEditButtonAttribute(editPermission, editRoute).' '.$this->getEditButtonAttribute("editPermission", "editRoute").'
'.$this->getDeleteButtonAttribute(deletePermission, deleteRoute).' '.$this->getDeleteButtonAttribute("deletePermission", "deleteRoute").'
</div>'; </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') @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') @section('page-header')
<h1> <h1>
{{ trans('labels.backend.modules.management') }} {{ trans('generator::labels.modules.management') }}
<small>{{ trans('labels.backend.modules.create') }}</small> <small>{{ trans('generator::labels.modules.create') }}</small>
</h1> </h1>
@endsection @endsection
@section('content') @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 box-success">
<div class="box-header with-border"> <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"> <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-tools pull-right-->
</div><!-- /.box-header --> </div><!-- /.box-header -->
{{-- Including Form blade file --}} {{-- Including Form blade file --}}
<div class="box-body"> <div class="box-body">
<div class="form-group"> <div class="form-group">
@include("backend.modules.form") @include("generator::form")
<div class="edit-form-btn"> <div class="edit-form-btn">
{{ link_to_route('admin.modules.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-md']) }} {{ 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']) }} {{ Form::submit(trans('buttons.general.crud.create'), ['class' => 'btn btn-primary btn-md']) }}
......
@extends ('backend.layouts.app') @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') @section('page-header')
<h1> <h1>
{{ trans('labels.backend.modules.management') }} {{ trans('generator::labels.modules.management') }}
<small>{{ trans('labels.backend.modules.edit') }}</small> <small>{{ trans('generator::labels.modules.edit') }}</small>
</h1> </h1>
@endsection @endsection
@section('content') @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 box-success">
<div class="box-header with-border"> <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"> <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-tools pull-right-->
</div><!-- /.box-header --> </div><!-- /.box-header -->
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</div> </div>
<!-- Module Name --> <!-- Module Name -->
<div class="form-group"> <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"> <div class="col-lg-10">
{{ Form::text('name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog', 'required' => 'required']) }} {{ Form::text('name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog', 'required' => 'required']) }}
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<!-- Directory --> <!-- Directory -->
<div class="form-group"> <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"> <div class="col-lg-10">
{{ Form::text('directory_name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog', 'required' => true]) }} {{ Form::text('directory_name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog', 'required' => true]) }}
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<!-- Model Name --> <!-- Model Name -->
<div class="form-group"> <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"> <div class="col-lg-10">
{{ Form::text('model_name', null, ['class' => 'form-control box-size only-text', 'placeholder' => 'e.g., Blog', 'required' => true]) }} {{ Form::text('model_name', null, ['class' => 'form-control box-size only-text', 'placeholder' => 'e.g., Blog', 'required' => true]) }}
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
<!-- Table Name --> <!-- Table Name -->
<div class="form-group"> <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"> <div class="col-lg-10">
{{ Form::text('table_name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog']) }} {{ Form::text('table_name', null, ['class' => 'form-control box-size', 'placeholder' => 'e.g., Blog']) }}
...@@ -77,10 +77,10 @@ ...@@ -77,10 +77,10 @@
<!-- Events --> <!-- Events -->
<div class="events-div"> <div class="events-div">
<div class="form-group event clearfix"> <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"> <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--> </div><!--col-lg-10-->
<a href="#" class="btn btn-danger btn-md remove-field hidden">Remove Event</a> <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> <a href="#" class="btn btn-primary btn-md add-field">Add Event</a>
...@@ -107,16 +107,9 @@ ...@@ -107,16 +107,9 @@
<!-- Override CheckBox --> <!-- Override CheckBox -->
<div class="form-group"> <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-2"></div>
<div class="col-lg-10"> <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> <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><!--form control-->
</div> </div>
<!-- end Override Checkbox --> <!-- end Override Checkbox -->
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<h3 class="box-title">{{ trans('labels.backend.modules.management') }}</h3> <h3 class="box-title">{{ trans('labels.backend.modules.management') }}</h3>
<div class="box-tools pull-right"> <div class="box-tools pull-right">
@include('backend.includes.partials.modules-header-buttons') @include('generator::partials.modules-header-buttons')
</div> </div>
</div><!-- /.box-header --> </div><!-- /.box-header -->
......
<!--Action Button--> <!--Action Button-->
@if(Active::checkUriPattern('admin/menus')) @if(Active::checkUriPattern('admin/modules'))
<div class="btn-group"> <div class="btn-group">
<button type="button" class="btn btn-warning btn-flat dropdown-toggle" data-toggle="dropdown">Export <button type="button" class="btn btn-warning btn-flat dropdown-toggle" data-toggle="dropdown">Export
<span class="caret"></span> <span class="caret"></span>
...@@ -21,10 +21,9 @@ ...@@ -21,10 +21,9 @@
<span class="sr-only">Toggle Dropdown</span> <span class="sr-only">Toggle Dropdown</span>
</button> </button>
<ul class="dropdown-menu" role="menu"> <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> <li><a href="{{route('admin.modules.index')}}"><i class="fa fa-list-ul"></i> {{trans('menus.backend.modules.all')}}</a></li>
@permission('create-menu') <li><a href="{{route('admin.modules.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.modules.create')}}</a></li>
<li><a href="{{route('admin.menus.create')}}"><i class="fa fa-plus"></i> {{trans('menus.backend.menus.create')}}</a></li>
@endauth
</ul> </ul>
</div> </div>
<div class="clearfix"></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