mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 21:54:14 -08:00
Added location clone
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
78b36c7886
commit
dac877f184
|
@ -227,6 +227,35 @@ class LocationsController extends Controller
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a view that presents a form to clone a location.
|
||||||
|
*
|
||||||
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
|
* @param int $licenseId
|
||||||
|
* @since [v6.0.14]
|
||||||
|
* @return View
|
||||||
|
*/
|
||||||
|
public function getClone($licenseId = null)
|
||||||
|
{
|
||||||
|
// Check if the asset exists
|
||||||
|
if (is_null($location_to_clone = Location::find($licenseId))) {
|
||||||
|
// Redirect to the asset management page
|
||||||
|
return redirect()->route('licenses.index')->with('error', trans('admin/locations/message.does_not_exist'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->authorize('create', $location_to_clone);
|
||||||
|
|
||||||
|
$location = clone $location_to_clone;
|
||||||
|
$location->id = null;
|
||||||
|
$location->name = null;
|
||||||
|
$location->image = null;
|
||||||
|
|
||||||
|
return view('locations/edit')
|
||||||
|
->with('item', $location);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function print_all_assigned($id)
|
public function print_all_assigned($id)
|
||||||
{
|
{
|
||||||
if ($location = Location::where('id', $id)->first()) {
|
if ($location = Location::where('id', $id)->first()) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use App\Models\Location;
|
use App\Models\Location;
|
||||||
use Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ class LocationsTransformer
|
||||||
$permissions_array['available_actions'] = [
|
$permissions_array['available_actions'] = [
|
||||||
'update' => Gate::allows('update', Location::class) ? true : false,
|
'update' => Gate::allows('update', Location::class) ? true : false,
|
||||||
'delete' => $location->isDeletable(),
|
'delete' => $location->isDeletable(),
|
||||||
|
'clone' => (Gate::allows('create', Location::class) && ($location->deleted_at == '')),
|
||||||
];
|
];
|
||||||
|
|
||||||
$array += $permissions_array;
|
$array += $permissions_array;
|
||||||
|
|
|
@ -40,12 +40,9 @@ Route::group(['middleware' => 'auth'], function () {
|
||||||
'parameters' => ['category' => 'category_id'],
|
'parameters' => ['category' => 'category_id'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/*
|
Route::get('locations/{locationId}/clone',
|
||||||
* Locations
|
[LocationsController::class, 'getClone']
|
||||||
*/
|
)->name('clone/license');
|
||||||
Route::resource('locations', LocationsController::class, [
|
|
||||||
'parameters' => ['location' => 'location_id'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
Route::get(
|
Route::get(
|
||||||
'locations/{locationId}/printassigned',
|
'locations/{locationId}/printassigned',
|
||||||
|
@ -57,6 +54,17 @@ Route::group(['middleware' => 'auth'], function () {
|
||||||
[LocationsController::class, 'print_all_assigned']
|
[LocationsController::class, 'print_all_assigned']
|
||||||
)->name('locations.print_all_assigned');
|
)->name('locations.print_all_assigned');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Locations
|
||||||
|
*/
|
||||||
|
Route::resource('locations', LocationsController::class, [
|
||||||
|
'parameters' => ['location' => 'location_id'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Manufacturers
|
* Manufacturers
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue