Small refactoring for code quality

This commit is contained in:
snipe 2017-10-27 17:38:11 -07:00
parent a224904ade
commit ec68bd7842
2 changed files with 6 additions and 15 deletions

View file

@ -100,8 +100,6 @@ class AccessoriesController extends Controller
{
$this->authorize('view', Accessory::class);
$accessory = Accessory::findOrFail($id);
$accessory_users = $accessory->users;
return (new AccessoriesTransformer)->transformAccessory($accessory);
}

View file

@ -614,7 +614,7 @@ class AssetsController extends Controller
->with('use_currency', $use_currency)->with('audit_log', $audit_log);
}
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist', compact('id')));
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
}
/**
@ -912,22 +912,19 @@ class AssetsController extends Controller
$destinationPath = config('app.private_uploads').'/assets';
if (Input::hasFile('assetfile')) {
if ($request->file('image')) {
foreach (Input::file('assetfile') as $file) {
$extension = $file->getClientOriginalExtension();
$filename = 'hardware-'.$asset->id.'-'.str_random(8);
$filename .= '-'.str_slug($file->getClientOriginalName()).'.'.$extension;
$upload_success = $file->move($destinationPath, $filename);
//Log the deletion of seats to the log
$file->move($destinationPath, $filename);
$asset->logUpload($filename, e(Input::get('notes')));
}
return redirect()->back()->with('success', trans('admin/hardware/message.upload.success'));
} else {
return redirect()->back()->with('error', trans('admin/hardware/message.upload.nofiles'));
}
if ($upload_success) {
return redirect()->back()->with('success', trans('admin/hardware/message.upload.success'));
}
return redirect()->back()->with('error', trans('admin/hardware/message.upload.error'));
}
@ -958,11 +955,9 @@ class AssetsController extends Controller
$log->delete();
return redirect()->back()->with('success', trans('admin/hardware/message.deletefile.success'));
}
// Prepare the error message
$error = trans('admin/hardware/message.does_not_exist', compact('id'));
// Redirect to the hardware management page
return redirect()->route('hardware.index')->with('error', $error);
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
}
/**
@ -1010,8 +1005,6 @@ class AssetsController extends Controller
{
$this->authorize('update', Asset::class);
if (!$request->has('ids')) {
return redirect()->back()->with('error', 'No assets selected');
}
@ -1224,7 +1217,7 @@ class AssetsController extends Controller
public function audit(Request $request, $id)
public function audit($id)
{
$this->authorize('audit', Asset::class);
$dt = Carbon::now()->addMonths(12)->toDateString();