Tie into tag generation

This commit is contained in:
Cram42 2022-11-01 20:02:12 +08:00
parent d37605ff18
commit 7b29ddd283
2 changed files with 8 additions and 4 deletions

View file

@ -13,6 +13,7 @@ use App\Models\Company;
use App\Models\Location; use App\Models\Location;
use App\Models\Setting; use App\Models\Setting;
use App\Models\User; use App\Models\User;
use App\View\Label;
use Auth; use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use DB; use DB;
@ -441,11 +442,12 @@ class AssetsController extends Controller
* @since [v3.0] * @since [v3.0]
* @return Redirect * @return Redirect
*/ */
public function getAssetByTag(Request $request) public function getAssetByTag($tag=null, Request $request)
{ {
$tag = $tag ? $tag : $request->get('assetTag');
$topsearch = ($request->get('topsearch') == 'true'); $topsearch = ($request->get('topsearch') == 'true');
if (! $asset = Asset::where('asset_tag', '=', $request->get('assetTag'))->first()) { if (! $asset = Asset::where('asset_tag', '=', $tag)->first()) {
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist')); return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
} }
$this->authorize('view', $asset); $this->authorize('view', $asset);
@ -542,9 +544,10 @@ class AssetsController extends Controller
$asset = Asset::find($assetId); $asset = Asset::find($assetId);
$this->authorize('view', $asset); $this->authorize('view', $asset);
return view('hardware/labels') return (new Label())
->with('assets', collect([ $asset ])) ->with('assets', collect([ $asset ]))
->with('settings', Setting::getSettings()) ->with('settings', Setting::getSettings())
->with('offset', request()->get('offset'))
->with('bulkedit', false) ->with('bulkedit', false)
->with('count', 0); ->with('count', 0);
} }

View file

@ -8,6 +8,7 @@ use App\Http\Controllers\CheckInOutRequest;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Asset; use App\Models\Asset;
use App\Models\Setting; use App\Models\Setting;
use App\View\Label;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@ -44,7 +45,7 @@ class BulkAssetsController extends Controller
if ($request->filled('bulk_actions')) { if ($request->filled('bulk_actions')) {
switch ($request->input('bulk_actions')) { switch ($request->input('bulk_actions')) {
case 'labels': case 'labels':
return view('hardware/labels') return (new Label)
->with('assets', Asset::find($asset_ids)) ->with('assets', Asset::find($asset_ids))
->with('settings', Setting::getSettings()) ->with('settings', Setting::getSettings())
->with('bulkedit', true) ->with('bulkedit', true)