Commit e8bd9d7d authored by Vipul Basapati's avatar Vipul Basapati Committed by StyleCI Bot

Apply fixes from StyleCI

parent bf7ae98d
......@@ -2,16 +2,15 @@
namespace App\Http\Controllers\Backend\Menu;
use App\Models\Menu\Menu;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Repositories\Backend\Menu\MenuRepository;
use App\Http\Requests\Backend\Menu\StoreMenuRequest;
use App\Http\Requests\Backend\Menu\ManageMenuRequest;
use App\Http\Requests\Backend\Menu\CreateMenuRequest;
use App\Http\Requests\Backend\Menu\EditMenuRequest;
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
......@@ -28,6 +27,7 @@ class MenuController extends Controller
/**
* Display a listing of the resource.
*
* @param \App\Http\Requests\Backend\Menu\ManageMenuRequest $request
*
* @return \Illuminate\Http\Response
......@@ -39,6 +39,7 @@ class MenuController extends Controller
/**
* Show the form for creating a new resource.
*
* @param \App\Http\Requests\Backend\Menu\CreateMenuRequest $request
*
* @return \Illuminate\Http\Response
......@@ -46,17 +47,19 @@ class MenuController extends Controller
public function create(CreateMenuRequest $request)
{
$types = [
"backend" => "Backend",
"frontend" => "Frontend"
'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 \App\Http\Requests\Backend\Menu\StoreMenuRequest $request
*
*
* @return \Illuminate\Http\Response
*/
public function store(StoreMenuRequest $request)
......@@ -68,19 +71,21 @@ class MenuController extends Controller
/**
* Show the form for editing the specified resource.
* @param \App\Models\Menu\Menu $menu
*
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\EditMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
public function edit(Menu $menu, EditMenuRequest $request)
{
$types = [
"backend" => "Backend",
"frontend" => "Frontend"
'backend' => 'Backend',
'frontend' => 'Frontend',
];
$modules = DB::table('modules')->get();
return view('backend.menus.edit')
->with('types', $types)
->with('menu', $menu)
......@@ -90,9 +95,9 @@ class MenuController extends Controller
/**
* Update the specified resource in storage.
*
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\UpdateMenuRequest $request
*
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\UpdateMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
public function update(Menu $menu, UpdateMenuRequest $request)
......@@ -106,8 +111,10 @@ class MenuController extends Controller
/**
* Remove the specified resource from storage.
* @param \App\Models\Menu\Menu $menu
*
* @param \App\Models\Menu\Menu $menu
* @param \App\Http\Requests\Backend\Menu\DeleteMenuRequest $request
*
* @return \Illuminate\Http\Response
*/
public function destroy(Menu $menu, DeleteMenuRequest $request)
......
......@@ -9,6 +9,7 @@ class MenuFormController extends Controller
{
/**
* Get the form for modal popup.
*
* @param string $formName
* @param \App\Http\Requests\Backend\Menu\CreateMenuRequest
*
......@@ -16,10 +17,10 @@ class MenuFormController extends Controller
*/
public function create($formName, CreateMenuRequest $request)
{
if(in_array($formName, ['_add_custom_url_form']))
{
if (in_array($formName, ['_add_custom_url_form'])) {
return view('backend.menus.'.$formName);
}
return abort(404);
}
}
\ No newline at end of file
}
......@@ -2,12 +2,11 @@
namespace App\Http\Controllers\Backend\Menu;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Yajra\DataTables\Facades\DataTables;
use App\Repositories\Backend\Menu\MenuRepository;
use App\Http\Requests\Backend\Menu\ManageMenuRequest;
use App\Repositories\Backend\Menu\MenuRepository;
use Carbon\Carbon;
use Yajra\DataTables\Facades\DataTables;
/**
* Class MenuTableController.
......
......@@ -5,7 +5,7 @@ namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class CreateMenuRequest
* Class CreateMenuRequest.
*/
class CreateMenuRequest extends Request
{
......
......@@ -5,7 +5,7 @@ namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class DeleteMenuRequest
* Class DeleteMenuRequest.
*/
class DeleteMenuRequest extends Request
{
......
......@@ -5,7 +5,7 @@ namespace App\Http\Requests\Backend\Menu;
use App\Http\Requests\Request;
/**
* Class EditMenuRequest
* Class EditMenuRequest.
*/
class EditMenuRequest extends Request
{
......
......@@ -2,9 +2,9 @@
namespace App\Models\Menu;
use Illuminate\Database\Eloquent\Model;
use App\Models\ModelTrait;
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
......@@ -25,12 +25,12 @@ class Menu extends Model
protected $fillable = [
'name',
'type',
'items'
'items',
];
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->table = config("access.menus_table");
$this->table = config('access.menus_table');
}
}
......@@ -13,8 +13,8 @@ trait MenuAttribute
public function getActionButtonsAttribute()
{
return '<div class="btn-group action-btn">
' .$this->getEditButtonAttribute('edit-menu', 'admin.menus.edit'). '
' .$this->getDeleteButtonAttribute('delete-menu', 'admin.menus.destroy'). '
'.$this->getEditButtonAttribute('edit-menu', 'admin.menus.edit').'
'.$this->getDeleteButtonAttribute('delete-menu', 'admin.menus.destroy').'
</div>';
}
}
......@@ -2,18 +2,17 @@
namespace App\Repositories\Backend\Menu;
use App\Repositories\BaseRepository;
use App\Exceptions\GeneralException;
use App\Models\Menu\Menu;
use App\Repositories\BaseRepository;
use Illuminate\Database\Eloquent\Model;
use DB;
/**
* Class MenuRepository.
*/
class MenuRepository extends BaseRepository
{
/**
/**
* Associated Repository Model.
*/
const MODEL = Menu::class;
......@@ -63,13 +62,12 @@ class MenuRepository extends BaseRepository
*
* return bool
*/
public function update(Menu $menu, array $input)
{
if ($this->query()->where('name', $input['name'])->where("id", '!=', $menu->id)->first()) {
if ($this->query()->where('name', $input['name'])->where('id', '!=', $menu->id)->first()) {
throw new GeneralException(trans('exceptions.backend.menus.already_exists'));
}
$input['updated_by'] = access()->user()->id;
if ($menu->update($input)) {
......@@ -77,7 +75,6 @@ class MenuRepository extends BaseRepository
}
throw new GeneralException(trans('exceptions.backend.menus.update_error'));
}
/**
......@@ -95,4 +92,4 @@ class MenuRepository extends BaseRepository
throw new GeneralException(trans('exceptions.backend.menus.delete_error'));
}
}
\ No newline at end of file
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateMenusTable extends Migration
{
......
<?php
use Carbon\Carbon;
use Database\TruncateTable;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
......@@ -18,10 +17,10 @@ class MenuTableSeeder extends Seeder
$menu = [
'id' => 1,
'type' => 'backend',
'name' => "Backend Sidebar Menu",
'name' => 'Backend Sidebar Menu',
'items' => '[{"view_permission_id":"view-access-management","icon":"fa-users","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"}]},{"view_permission_id":"view-module","icon":"fa-wrench","open_in_new_tab":0,"url_type":"route","url":"admin.modules.index","name":"Module","id":1,"content":"Module"},{"view_permission_id":"view-menu","icon":"fa-bars","open_in_new_tab":0,"url_type":"route","url":"admin.menus.index","name":"Menus","id":3,"content":"Menus"},{"view_permission_id":"view-page","icon":"fa-file-text","open_in_new_tab":0,"url_type":"route","url":"admin.pages.index","name":"Pages","id":2,"content":"Pages"},{"view_permission_id":"view-email-template","icon":"fa-envelope","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","icon":"fa-gear","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","icon":"fa-commenting","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","icon":"fa-question-circle","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()
'created_at' => Carbon::now(),
];
DB::table(config('access.menus_table'))->insert($menu);
......
......@@ -6,7 +6,6 @@ use Illuminate\Support\Facades\DB;
class ModulesTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
......@@ -22,98 +21,98 @@ class ModulesTableSeeder extends Seeder
'url' => null,
'view_permission_id' => 'view-access-management',
'created_by' => 1,
'created_at' => Carbon::now()
'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()
'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()
'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()
'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()
'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()
'created_at' => Carbon::now(),
],
[
'name' => trans('labels.backend.pages.title'),
'url' => 'admin.pages.index',
'view_permission_id' => 'view-page',
'created_by' => 1,
'created_at' => Carbon::now()
'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()
'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()
'created_at' => Carbon::now(),
],
[
'name' => trans('menus.backend.blog.management'),
'url' => null,
'view_permission_id' => 'view-blog',
'created_by' => 1,
'created_at' => Carbon::now()
'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()
'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()
'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()
'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()
'created_at' => Carbon::now(),
],
];
......
<?php
/**
* Menu Management
* 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
// for Model Forms
Route::get('menus/get-form/{name?}', 'MenuFormController@create')->name('menus.getform');
});
\ No newline at end of file
});
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