cloning accessories first bit

This commit is contained in:
akemidx
2023-03-07 16:41:48 -05:00
parent d954c841e6
commit ec5836dab4
4 changed files with 45 additions and 1 deletions
@@ -115,6 +115,36 @@ class AccessoriesController extends Controller
}
/**
* Returns a view that presents a form to clone an accessory.
*
* @author [J. Vinsmoke]
* @param int $accessoryId
* @since [v6.0]
* @return View
*/
public function getClone($accessoryId = null)
{
$this->authorize('create', Accesory::class);
// Check if the asset exists
if (is_null($accessory_to_clone = Accessory::find($accessoryId))) {
// Redirect to the asset management page
return redirect()->route('accessory.index')->with('error', trans('admin/accessories/message.does_not_exist'));
}
$accessory = clone $accessory_to_clone;
$accessory->id = null;
$accessory->location_id = null;
//duplicate the image for the cloned accessory
copy('uploads/accessories/usb-keyboard.jpg','uploads/accessories/testimage.jpg');
return view('accessories/edit')
->with('item', $accessory);
}
/**
* Save edited Accessory from form post