More tweaks to the controllers, more breadcrumbs
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
989082d719
commit
3954ff20b4
13 changed files with 92 additions and 111 deletions
|
@ -88,14 +88,10 @@ class CategoriesController extends Controller
|
|||
* @param int $categoryId
|
||||
* @since [v1.0]
|
||||
*/
|
||||
public function edit($categoryId = null) : RedirectResponse | View
|
||||
public function edit(Category $category) : RedirectResponse | View
|
||||
{
|
||||
$this->authorize('update', Category::class);
|
||||
if (is_null($item = Category::find($categoryId))) {
|
||||
return redirect()->route('categories.index')->with('error', trans('admin/categories/message.does_not_exist'));
|
||||
}
|
||||
|
||||
return view('categories/edit', compact('item'))
|
||||
return view('categories/edit')->with('item', $category)
|
||||
->with('category_types', Helper::categoryTypeList());
|
||||
}
|
||||
|
||||
|
@ -108,19 +104,10 @@ class CategoriesController extends Controller
|
|||
* @param int $categoryId
|
||||
* @since [v1.0]
|
||||
*/
|
||||
public function update(ImageUploadRequest $request, $categoryId = null) : RedirectResponse
|
||||
public function update(ImageUploadRequest $request, Category $category) : RedirectResponse
|
||||
{
|
||||
$this->authorize('update', Category::class);
|
||||
if (is_null($category = Category::find($categoryId))) {
|
||||
// Redirect to the categories management page
|
||||
return redirect()->route('categories.index')->with('error', trans('admin/categories/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// Update the category data
|
||||
$category->name = $request->input('name');
|
||||
// If the item count is > 0, we disable the category type in the edit. Disabled items
|
||||
// don't POST, so if the category_type is blank we just set it to the default.
|
||||
|
||||
|
||||
// Don't allow the user to change the category_type once it's been created
|
||||
if (($request->filled('category_type') && ($category->itemCount() > 0))) {
|
||||
|
@ -181,10 +168,10 @@ class CategoriesController extends Controller
|
|||
* @param $id
|
||||
* @since [v1.8]
|
||||
*/
|
||||
public function show($id) : View | RedirectResponse
|
||||
public function show(Category $category) : View | RedirectResponse
|
||||
{
|
||||
$this->authorize('view', Category::class);
|
||||
if ($category = Category::find($id)) {
|
||||
|
||||
if ($category->category_type == 'asset') {
|
||||
$category_type = 'hardware';
|
||||
$category_type_route = 'assets';
|
||||
|
@ -199,8 +186,5 @@ class CategoriesController extends Controller
|
|||
return view('categories/view', compact('category'))
|
||||
->with('category_type', $category_type)
|
||||
->with('category_type_route', $category_type_route);
|
||||
}
|
||||
|
||||
return redirect()->route('categories.index')->with('error', trans('admin/categories/message.does_not_exist'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ class DepreciationsController extends Controller
|
|||
{
|
||||
|
||||
$this->authorize('update', $depreciation);
|
||||
return view('depreciations/edit');
|
||||
return view('depreciations/edit')->with('item', $depreciation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -79,19 +79,12 @@ class GroupsController extends Controller
|
|||
* @param int $id
|
||||
* @since [v1.0]
|
||||
*/
|
||||
public function edit($id) : View | RedirectResponse
|
||||
public function edit(Group $group) : View | RedirectResponse
|
||||
{
|
||||
$group = Group::find($id);
|
||||
|
||||
if ($group) {
|
||||
$permissions = config('permissions');
|
||||
$groupPermissions = $group->decodePermissions();
|
||||
$selected_array = Helper::selectedPermissionsArray($permissions, $groupPermissions);
|
||||
|
||||
return view('groups.edit', compact('group', 'permissions', 'selected_array', 'groupPermissions'));
|
||||
}
|
||||
|
||||
return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', ['id' => $id]));
|
||||
$permissions = config('permissions');
|
||||
$groupPermissions = $group->decodePermissions();
|
||||
$selected_array = Helper::selectedPermissionsArray($permissions, $groupPermissions);
|
||||
return view('groups.edit', compact('permissions', 'selected_array', 'groupPermissions'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,11 +95,8 @@ class GroupsController extends Controller
|
|||
* @param int $id
|
||||
* @since [v1.0]
|
||||
*/
|
||||
public function update(Request $request, $id = null) : RedirectResponse
|
||||
public function update(Request $request, Group $group) : RedirectResponse
|
||||
{
|
||||
if (! $group = Group::find($id)) {
|
||||
return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', ['id' => $id]));
|
||||
}
|
||||
$group->name = $request->input('name');
|
||||
$group->permissions = json_encode($request->input('permission'));
|
||||
$group->notes = $request->input('notes');
|
||||
|
@ -151,14 +141,8 @@ class GroupsController extends Controller
|
|||
* @param $id
|
||||
* @since [v4.0.11]
|
||||
*/
|
||||
public function show($id) : View | RedirectResponse
|
||||
public function show(Group $group) : View | RedirectResponse
|
||||
{
|
||||
$group = Group::find($id);
|
||||
|
||||
if ($group) {
|
||||
return view('groups/view', compact('group'));
|
||||
}
|
||||
|
||||
return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', ['id' => $id]));
|
||||
return view('groups/view');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,9 @@ class StatuslabelsController extends Controller
|
|||
|
||||
$statuslabel_types = ['' => trans('admin/hardware/form.select_statustype')] + ['undeployable' => trans('admin/hardware/general.undeployable')] + ['pending' => trans('admin/hardware/general.pending')] + ['archived' => trans('admin/hardware/general.archived')] + ['deployable' => trans('admin/hardware/general.deployable')];
|
||||
|
||||
return view('statuslabels/edit', compact('statuslabel_types'))->with('use_statuslabel_type', $statuslabel);
|
||||
return view('statuslabels/edit', compact('statuslabel_types'))
|
||||
->with('item', $statuslabel)
|
||||
->with('use_statuslabel_type', $statuslabel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -80,7 +80,7 @@ class SuppliersController extends Controller
|
|||
public function edit(Supplier $supplier) : View | RedirectResponse
|
||||
{
|
||||
$this->authorize('update', Supplier::class);
|
||||
return view('suppliers/edit');
|
||||
return view('suppliers/edit')->with('item', $supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use App\Models\Accessory;
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\Component;
|
||||
use App\Models\Consumable;
|
||||
|
@ -105,6 +106,31 @@ class BreadcrumbsServiceProvider extends ServiceProvider
|
|||
);
|
||||
|
||||
|
||||
/**
|
||||
* Categories Breadcrumbs
|
||||
*/
|
||||
Breadcrumbs::for('categories.index', fn (Trail $trail) =>
|
||||
$trail->parent('home', route('home'))
|
||||
->push(trans('general.categories'), route('categories.index'))
|
||||
);
|
||||
|
||||
Breadcrumbs::for('categories.create', fn (Trail $trail) =>
|
||||
$trail->parent('categories.index', route('categories.index'))
|
||||
->push(trans('general.create'), route('home'))
|
||||
);
|
||||
|
||||
Breadcrumbs::for('categories.show', fn (Trail $trail, Category $category) =>
|
||||
$trail->parent('categories.index', route('categories.index'))
|
||||
->push('View '.$category->name, route('home'))
|
||||
);
|
||||
|
||||
Breadcrumbs::for('categories.edit', fn (Trail $trail, Category $category) =>
|
||||
$trail->parent('categories.index', route('categories.index'))
|
||||
->push('Edit: '.$category->name, route('home'))
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Company Breadcrumbs
|
||||
*/
|
||||
|
@ -249,7 +275,6 @@ class BreadcrumbsServiceProvider extends ServiceProvider
|
|||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Licenses Breadcrumbs
|
||||
*/
|
||||
|
@ -296,6 +321,7 @@ class BreadcrumbsServiceProvider extends ServiceProvider
|
|||
->push('Edit: '.$location->name, route('home'))
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Manufacturers Breadcrumbs
|
||||
*/
|
||||
|
|
|
@ -587,4 +587,6 @@ return [
|
|||
'notes' => 'Add a note',
|
||||
],
|
||||
|
||||
'generic_model_not_found' => ':model not found',
|
||||
|
||||
];
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
'topSubmit' => true,
|
||||
'helpText' => trans('help.assets'),
|
||||
'helpPosition' => 'right',
|
||||
'formAction' => ($item->id) ? route('hardware.update', ['hardware' => $item->id]) : route('hardware.store'),
|
||||
'formAction' => ($item->id) ? route('hardware.update', $item) : route('hardware.store'),
|
||||
'index_route' => 'hardware.index',
|
||||
'options' => [
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'assets']),
|
||||
|
|
|
@ -826,52 +826,55 @@ dir="{{ Helper::determineLanguageDirection() }}">
|
|||
@endif
|
||||
|
||||
<!-- Content Header (Page header) -->
|
||||
<section class="content-header" style="padding-bottom: 30px;">
|
||||
<section class="content-header">
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12" style="margin-bottom: 10px;">
|
||||
<div class="col-md-12">
|
||||
|
||||
<style>
|
||||
.breadcrumb-item {
|
||||
display: inline;
|
||||
list-style: none;
|
||||
font-size: 110%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@if(Breadcrumbs::has())
|
||||
@foreach (Breadcrumbs::current() as $crumbs)
|
||||
@if ($crumbs->url() && !$loop->last)
|
||||
<li class="breadcrumb-item">
|
||||
<a href="{{ $crumbs->url() }}">
|
||||
<h1 class="pull-left pagetitle" style="font-size: 22px; margin-top: 10px;">
|
||||
|
||||
@if (Breadcrumbs::has() && (Breadcrumbs::current()->count() > 1))
|
||||
|
||||
@foreach (Breadcrumbs::current() as $crumbs)
|
||||
@if ($crumbs->url() && !$loop->last)
|
||||
<li class="breadcrumb-item">
|
||||
<a href="{{ $crumbs->url() }}">
|
||||
{{ $crumbs->title() }}
|
||||
</a> <i class="fa-solid fa-angle-right"></i>
|
||||
</li>
|
||||
@else
|
||||
<li class="breadcrumb-item active">
|
||||
{{ $crumbs->title() }}
|
||||
</a> <i class="fa-solid fa-angle-right"></i>
|
||||
</li>
|
||||
@else
|
||||
<li class="breadcrumb-item active">
|
||||
{{ $crumbs->title() }}
|
||||
</li>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
</li>
|
||||
@endif
|
||||
@endforeach
|
||||
@else
|
||||
@yield('title')
|
||||
@endif
|
||||
|
||||
</h1>
|
||||
|
||||
@if (isset($helpText))
|
||||
@include ('partials.more-info',
|
||||
[
|
||||
'helpText' => $helpText,
|
||||
'helpPosition' => (isset($helpPosition)) ? $helpPosition : 'left'
|
||||
])
|
||||
@endif
|
||||
<div class="pull-right">
|
||||
@yield('header_right')
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h1 class="pull-left pagetitle">@yield('title') </h1>
|
||||
|
||||
@if (isset($helpText))
|
||||
@include ('partials.more-info',
|
||||
[
|
||||
'helpText' => $helpText,
|
||||
'helpPosition' => (isset($helpPosition)) ? $helpPosition : 'left'
|
||||
])
|
||||
@endif
|
||||
<div class="pull-right">
|
||||
@yield('header_right')
|
||||
</div>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
|
|
@ -109,23 +109,17 @@ Route::group(['middleware' => 'auth'], function () {
|
|||
/*
|
||||
* Suppliers
|
||||
*/
|
||||
Route::resource('suppliers', SuppliersController::class, [
|
||||
'parameters' => ['supplier' => 'supplier_id'],
|
||||
]);
|
||||
Route::resource('suppliers', SuppliersController::class);
|
||||
|
||||
/*
|
||||
* Depreciations
|
||||
*/
|
||||
Route::resource('depreciations', DepreciationsController::class, [
|
||||
'parameters' => ['depreciation' => 'depreciation_id'],
|
||||
]);
|
||||
Route::resource('depreciations', DepreciationsController::class);
|
||||
|
||||
/*
|
||||
* Status Labels
|
||||
*/
|
||||
Route::resource('statuslabels', StatuslabelsController::class, [
|
||||
'parameters' => ['statuslabel' => 'statuslabel_id'],
|
||||
]);
|
||||
Route::resource('statuslabels', StatuslabelsController::class);
|
||||
|
||||
/*
|
||||
* Departments
|
||||
|
@ -188,8 +182,6 @@ Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuser
|
|||
Route::get('security', [SettingsController::class, 'getSecurity'])->name('settings.security.index');
|
||||
Route::post('security', [SettingsController::class, 'postSecurity'])->name('settings.security.save');
|
||||
|
||||
Route::get('groups', [GroupsController::class, 'index'])->name('settings.groups.index');
|
||||
|
||||
Route::get('localization', [SettingsController::class, 'getLocalization'])->name('settings.localization.index');
|
||||
Route::post('localization', [SettingsController::class, 'postLocalization'])->name('settings.localization.save');
|
||||
|
||||
|
@ -248,10 +240,7 @@ Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuser
|
|||
Route::get('/', [SettingsController::class, 'getBackups'])->name('settings.backups.index');
|
||||
});
|
||||
|
||||
Route::resource('groups', GroupsController::class, [
|
||||
'middleware' => ['auth'],
|
||||
'parameters' => ['group' => 'group_id'],
|
||||
]);
|
||||
Route::resource('groups', GroupsController::class);
|
||||
|
||||
Route::get('/', [SettingsController::class, 'index'])->name('settings.index');
|
||||
});
|
||||
|
|
|
@ -53,6 +53,5 @@ Route::group(['prefix' => 'accessories', 'middleware' => ['auth']], function ()
|
|||
});
|
||||
|
||||
Route::resource('accessories', Accessories\AccessoriesController::class, [
|
||||
'middleware' => ['auth'],
|
||||
'parameters' => ['accessory' => 'accessory_id'],
|
||||
'middleware' => ['auth']
|
||||
]);
|
||||
|
|
|
@ -171,17 +171,10 @@ Route::group(
|
|||
|
||||
});
|
||||
|
||||
Route::resource('hardware',
|
||||
AssetsController::class,
|
||||
[
|
||||
'middleware' => ['auth'],
|
||||
'parameters' => [
|
||||
'names' => [
|
||||
'show' => 'view',
|
||||
'index' => 'index',
|
||||
],
|
||||
],
|
||||
]);
|
||||
Route::resource('hardware',
|
||||
AssetsController::class,
|
||||
['middleware' => ['auth']
|
||||
])->parameters(['hardware' => 'asset']);
|
||||
|
||||
Route::get('ht/{any?}',
|
||||
[AssetsController::class, 'getAssetByTag']
|
||||
|
|
|
@ -151,6 +151,5 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () {
|
|||
|
||||
Route::resource('users', Users\UsersController::class, [
|
||||
'middleware' => ['auth'],
|
||||
'parameters' => ['user' => 'user_id'],
|
||||
'except' => ['update']
|
||||
]);
|
||||
|
|
Loading…
Add table
Reference in a new issue