Added clone to consumables

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-07-20 16:40:32 +01:00
parent 2bfee0c29a
commit 254e2f120b
3 changed files with 15 additions and 0 deletions

View file

@ -209,4 +209,14 @@ class ConsumablesController extends Controller
return redirect()->route('consumables.index') return redirect()->route('consumables.index')
->with('error', trans('admin/consumables/message.does_not_exist')); ->with('error', trans('admin/consumables/message.does_not_exist'));
} }
public function clone(Consumable $consumable) : View
{
$this->authorize('create', $consumable);
$consumable_to_close = $consumable;
$consumable = clone $consumable_to_close;
$consumable->id = null;
return view('consumables/edit')->with('item', $consumable);
}
} }

View file

@ -55,6 +55,7 @@ class ConsumablesTransformer
'checkin' => Gate::allows('checkin', Consumable::class), 'checkin' => Gate::allows('checkin', Consumable::class),
'update' => Gate::allows('update', Consumable::class), 'update' => Gate::allows('update', Consumable::class),
'delete' => Gate::allows('delete', Consumable::class), 'delete' => Gate::allows('delete', Consumable::class),
'clone' => (Gate::allows('create', Consumable::class) && ($consumable->deleted_at == '')),
]; ];
$array += $permissions_array; $array += $permissions_array;

View file

@ -31,6 +31,10 @@ Route::group(['prefix' => 'consumables', 'middleware' => ['auth']], function ()
[Consumables\ConsumablesFilesController::class, 'show'] [Consumables\ConsumablesFilesController::class, 'show']
)->name('show.consumablefile'); )->name('show.consumablefile');
Route::get('{consumable}/clone',
[Consumables\ConsumablesController::class, 'clone']
)->name('consumables.clone.create');
}); });