Commit 5119c782 authored by Vipul Basapati's avatar Vipul Basapati

Removed Module and Menu management and added package for module management --...

Removed Module and Menu management and added package for module management -- have to look for breadcrumbs not working
parent 07ff00a8
......@@ -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';
require __DIR__.'/LogViewer.php';
\ No newline at end of file
<?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
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\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\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\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'));
});
}
}
......@@ -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')) {
/**
* Converts items (json string) to array and return array.
......
......@@ -38,7 +38,8 @@
"database"
],
"psr-4": {
"App\\": "app/"
"App\\": "app/",
"Bvipul\\Generator\\": "packages/bvipul/generator/src/"
},
"files": [
"app/helpers.php"
......
......@@ -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 [
'table' => 'modules',
];
"table" => "modules",
"brands" => [
"table" => "brands",
],
];
\ No newline at end of file
<?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');
}
}
{
"name": "bvipul/generator",
"description": "To create a whole module with all related files like model, controller, repository, routes, views etc with a simple GUI.",
"type": "project",
"license": "MIT",
"authors": [
{
"name": "Vipul Basapati",
"email": "basapativipulkumar@gmail.com"
}
],
"autoload": {
},
"require": {
}
}
<?php
namespace App\Http\Utilities;
namespace Bvipul\Generator\Controllers;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Artisan;
......@@ -366,7 +366,7 @@ class Generator
*/
public function createModel()
{
$this->createDirectory($this->getBasePath($this->removeFileNameFromEndOfNamespace($this->attribute_namespace)));
$this->createDirectory($this->getBasePath($this->attribute_namespace, true));
//Generate Attribute File
$this->generateFile('Attribute', [
'AttributeNamespace' => ucfirst($this->removeFileNameFromEndOfNamespace($this->attribute_namespace)),
......@@ -410,7 +410,7 @@ class Generator
{
$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)),
......@@ -465,7 +465,7 @@ class Generator
*/
public function createRepository()
{
$this->createDirectory($this->getBasePath($this->repo_namespace));
$this->createDirectory($this->getBasePath($this->repo_namespace, true));
//Getting stub file content
$file_contents = $this->files->get($this->getStubPath().'Repository.stub');
//If Model Create is checked
......@@ -508,7 +508,6 @@ class Generator
*/
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');
......@@ -651,10 +650,8 @@ class Generator
$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);
$path = resource_path('lang'.DIRECTORY_SEPARATOR.'en');
//config folder path
$config_path = config_path('module.php');
//Creating directory if it isn't
......@@ -866,7 +863,12 @@ class Generator
*/
public function getStubPath()
{
return app_path('Console'.DIRECTORY_SEPARATOR.'Commands'.DIRECTORY_SEPARATOR.'Stubs'.DIRECTORY_SEPARATOR);
$path = resource_path('views'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'generator'.DIRECTORY_SEPARATOR.'Stubs'.DIRECTORY_SEPARATOR);
$package_stubs_path = base_path('vendor'.DIRECTORY_SEPARATOR.'bvipul'.DIRECTORY_SEPARATOR.'generator'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.'Stubs'.DIRECTORY_SEPARATOR);
if($this->files->exists($path))
return $path;
else
return $package_stubs_path;
}
public function getBasePath($namespace, $status = false)
......
<?php
namespace App\Http\Controllers\Backend\Module;
namespace Bvipul\Generator\Controllers;
use Illuminate\Http\Request;
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;
use Bvipul\Generator\Repositories\ModuleRepository;
/**
* Class ModuleController.
......@@ -39,9 +34,9 @@ class ModuleController extends Controller
*
* @return \Illuminate\Http\Response
*/
public function index(ManageModuleRequest $request)
public function index(Request $request)
{
return view('backend.modules.index');
return view('generator::index');
}
/**
......@@ -49,9 +44,9 @@ class ModuleController extends Controller
*
* @return \Illuminate\Http\Response
*/
public function create(CreateModuleRequest $request)
public function create(Request $request)
{
return view('backend.modules.create')
return view('generator::create')
->with('model_namespace', $this->generator->getModelNamespace())
->with('request_namespace', $this->generator->getRequestNamespace())
->with('controller_namespace', $this->generator->getControllerNamespace())
......@@ -68,7 +63,7 @@ class ModuleController extends Controller
*
* @return \Illuminate\Http\Response
*/
public function store(StoreModuleRequest $request)
public function store(Request $request)
{
$this->generator->initialize($request->all());
$this->generator->createMigration();
......@@ -189,7 +184,7 @@ class ModuleController extends Controller
return $model;
}
public function checkPermission(ManageModuleRequest $request)
public function checkPermission(Request $request)
{
$permission = $request->permission;
......
<?php
namespace App\Http\Controllers\Backend\Module;
namespace Bvipul\Generator\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\Modules\ManageModuleRequest;
use App\Repositories\Backend\Module\ModuleRepository;
use Yajra\DataTables\Facades\DataTables;
use Bvipul\Generator\Repositories\ModuleRepository;
class ModuleTableController extends Controller
{
......@@ -23,11 +23,11 @@ class ModuleTableController extends Controller
}
/**
* @param ManageModuleRequest $request
* @param Illuminate\Http\Request $request
*
* @return mixed
*/
public function __invoke(ManageModuleRequest $request)
public function __invoke(Request $request)
{
return Datatables::of($this->module->getForDataTable())
->escapeColumns(['name', 'url', 'view_permission_id'])
......
<?php
namespace App\Models\Module;
namespace Bvipul\Generator;
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 Bvipul\Generator\Provider;
use Illuminate\Support\ServiceProvider;
class CrudGeneratorServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
$this->loadViewsFrom(__DIR__.'/../views', 'generator');
$this->loadMigrationsFrom(__DIR__.'/../migrations');
$this->loadTranslationsFrom(__DIR__.'/../lang', 'generator');
$this->publishes([
__DIR__.'/../views' => base_path('resources/views/vendor/generator'),
]);
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
include __DIR__.'/../routes.php';
require __DIR__.'/../breadcrumbs.php';
require_once(__DIR__.'/../helpers.php');
$this->app->make('Bvipul\Generator\Module');
$this->app->make('Bvipul\Generator\Controllers\Generator');
$this->app->make('Bvipul\Generator\Controllers\ModuleController');
$this->app->make('Bvipul\Generator\Repositories\ModuleRepository');
$this->app->make('Bvipul\Generator\Controllers\ModuleTableController');
}
}
<?php
namespace App\Repositories\Backend\Module;
namespace Bvipul\Generator\Repositories;
use Bvipul\Generator\Module;
use App\Exceptions\GeneralException;
use App\Models\Access\Permission\Permission;
use App\Models\Module\Module;
use App\Repositories\BaseRepository;
use App\Models\Access\Permission\Permission;
/**
* Class ModuleRepository.
......@@ -23,15 +23,15 @@ class ModuleRepository extends BaseRepository
public function getForDataTable()
{
return $this->query()
->leftjoin(config('access.users_table'), config('access.users_table').'.id', '=', config('module.table').'.created_by')
->leftjoin('users', 'users.id', '=', 'modules.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',
'modules.id',
'modules.name',
'modules.url',
'modules.view_permission_id',
'modules.created_by',
'modules.updated_by',
'users.first_name as created_by',
]);
}
......@@ -45,16 +45,10 @@ class ModuleRepository extends BaseRepository
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 = [
......@@ -76,31 +70,10 @@ class ModuleRepository extends BaseRepository
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;
else {
return $module;
}
throw new GeneralException(
trans('exceptions.backend.modules.update_error')
);
throw new GeneralException('There was some error in creating the Module. Please Try Again.');
}
}
<?php
use DaveJamesMiller\Breadcrumbs\Facades\Breadcrumbs;
Breadcrumbs::register('admin.modules.index', function ($breadcrumbs) {
$breadcrumbs->parent('admin.dashboard');
$breadcrumbs->push(trans('menus.backend.modules.management'), route('admin.modules.index'));
$breadcrumbs->push(trans('generator::menus.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->push(trans('generator::menus.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));
$breadcrumbs->push(trans('generator::menus.modules.edit'), route('admin.modules.edit', $id));
});
<?php
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;
}
}
$file_contents_new = "<?php\nreturn [\n";
$file_contents_new .= get_array_contents($file_array);
$file_contents_new .= '];';
file_put_contents($file_name, $file_contents_new);
}
}
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;
}
}
\ No newline at end of file
<?php
return [
"modules" => [
"create" => "Create Module",
"management" => "Module Management",
"title" => "Module",
"edit" => "Edit Module",
"table" => [
"name" => "Module Name",
"url" => "Module View Route",
"view_permission_id" => "View Permission",
"created_by" => "Created By",
],
"form" => [
"name" => "Module Name",
"url" => "View Route",
"view_permission_id" => "View Permission",
"directory_name" => "Directory Name",
"namespace" => "Namespace",
"model_name" => "Model Name",
"controller_name" => "Controller &nbsp;Name",
"resource_controller" => "Resourceful Controller",
"table_controller_name" => "Controller &nbsp;Name",
"table_name" => "Table Name",
"route_name" => "Route Name",
"route_controller_name" => "Controller &nbsp;Name",
"resource_route" => "Resourceful Routes",
"views_directory" => "Directory &nbsp;&nbsp;&nbsp;Name",
"index_file" => "Index",
"create_file" => "Create",
"edit_file" => "Edit",
"form_file" => "Form",
"repo_name" => "Repository Name",
"event" => "Event Name",
],
]
];
\ No newline at end of file
<?php
return [
"modules" => [
"all" => "All Modules Page",
"create" => "Create Module Page",
"management" => "Module Management",
"main" => "Module Pages",
]
];
\ No newline at end of file
<?php
/**
* Module Generator Routes.
*/
Route::group(['namespace' => 'Module'], function () {
Route::resource('modules', 'ModuleController');
Route::group(['namespace' => 'Bvipul\Generator\Controllers', 'prefix' => 'admin', 'as' => 'admin.', 'middleware' => ['web', 'admin'] ], function () {
Route::resource('modules', 'ModuleController');
//For DataTables
Route::post('modules/get', 'ModuleTableController')
......@@ -15,4 +12,4 @@ Route::group(['namespace' => 'Module'], function () {
Route::post('modules/checkTable', 'ModuleController@checkTable')->name('modules.check.table');
//checking permission exists
Route::post('modules/checkPermission', 'ModuleController@checkPermission')->name('modules.check.permission');
});
});
\ 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
......@@ -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') }}">
......@@ -121,14 +113,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
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.
<?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');
});
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