mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
clean up
This commit is contained in:
parent
691faf6340
commit
2a352619f7
|
@ -14,9 +14,6 @@ use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
use App\Http\Requests\AssetCheckoutRequest;
|
use App\Http\Requests\AssetCheckoutRequest;
|
||||||
use App\Models\CustomField;
|
use App\Models\CustomField;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
|
|
||||||
use function Amp\Promise\wait;
|
|
||||||
|
|
||||||
class BulkAssetsController extends Controller
|
class BulkAssetsController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -33,9 +30,6 @@ class BulkAssetsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function edit(Request $request)
|
public function edit(Request $request)
|
||||||
{
|
{
|
||||||
// dd($request->all());
|
|
||||||
// dd(Session::get('ids'));
|
|
||||||
|
|
||||||
$this->authorize('view', Asset::class);
|
$this->authorize('view', Asset::class);
|
||||||
|
|
||||||
if (! $request->filled('ids')) {
|
if (! $request->filled('ids')) {
|
||||||
|
@ -59,12 +53,6 @@ class BulkAssetsController extends Controller
|
||||||
$modelNames[] = $model->model->name;
|
$modelNames[] = $model->model->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $custom_fields = new Collection();
|
|
||||||
// foreach ($models as $asset_key => $asset) {
|
|
||||||
// $custom_fields->push($asset->model->customFields);
|
|
||||||
// }
|
|
||||||
$custom_fields = $asset_custom_field->pluck('model.fieldset.fields')->flatten()->unique('id');
|
|
||||||
|
|
||||||
if ($request->filled('bulk_actions')) {
|
if ($request->filled('bulk_actions')) {
|
||||||
switch ($request->input('bulk_actions')) {
|
switch ($request->input('bulk_actions')) {
|
||||||
case 'labels':
|
case 'labels':
|
||||||
|
@ -98,7 +86,6 @@ class BulkAssetsController extends Controller
|
||||||
return view('hardware/bulk')
|
return view('hardware/bulk')
|
||||||
->with('assets', $asset_ids)
|
->with('assets', $asset_ids)
|
||||||
->with('statuslabel_list', Helper::statusLabelList())
|
->with('statuslabel_list', Helper::statusLabelList())
|
||||||
// ->with('custom_fields', $custom_fields)
|
|
||||||
->with('models', $models->pluck(['model']))
|
->with('models', $models->pluck(['model']))
|
||||||
->with('modelNames', $modelNames);
|
->with('modelNames', $modelNames);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +104,6 @@ class BulkAssetsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function update(Request $request)
|
public function update(Request $request)
|
||||||
{
|
{
|
||||||
// dd(request()->headers->get('referer'));
|
|
||||||
$this->authorize('update', Asset::class);
|
$this->authorize('update', Asset::class);
|
||||||
$error_bag = [];
|
$error_bag = [];
|
||||||
|
|
||||||
|
@ -161,7 +147,6 @@ class BulkAssetsController extends Controller
|
||||||
|| ($request->anyFilled($custom_field_columns))
|
|| ($request->anyFilled($custom_field_columns))
|
||||||
|
|
||||||
) {
|
) {
|
||||||
// dd($assets);
|
|
||||||
foreach ($assets as $assetId) {
|
foreach ($assets as $assetId) {
|
||||||
|
|
||||||
$this->update_array = [];
|
$this->update_array = [];
|
||||||
|
@ -252,29 +237,17 @@ class BulkAssetsController extends Controller
|
||||||
} else {
|
} else {
|
||||||
Asset::find($assetId)->update($this->update_array);
|
Asset::find($assetId)->update($this->update_array);
|
||||||
}
|
}
|
||||||
} // endforeach ($assets)
|
}
|
||||||
ray(['error_bag1' => $error_bag]);
|
|
||||||
if(!empty($error_bag)) {
|
if(!empty($error_bag)) {
|
||||||
// $errors = collect($error_bag)->unique();
|
|
||||||
// foreach ($errors as $key => $value) {
|
|
||||||
// ray($value->message);
|
|
||||||
// }
|
|
||||||
$errors = [];
|
$errors = [];
|
||||||
//find the customfield name from the name of the messagebag items
|
//find the customfield name from the name of the messagebag items
|
||||||
foreach ($error_bag as $key => $bag) {
|
foreach ($error_bag as $key => $bag) {
|
||||||
ray($bag->keys());
|
|
||||||
foreach($bag->keys() as $key => $value) {
|
foreach($bag->keys() as $key => $value) {
|
||||||
CustomField::where('db_column', $value)->get()->map(function($item) use (&$errors) {
|
CustomField::where('db_column', $value)->get()->map(function($item) use (&$errors) {
|
||||||
$errors[] = $item->name;
|
$errors[] = $item->name;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ray(['error_bag2' => $errors]);
|
|
||||||
|
|
||||||
// Session::save('ids', $assets);
|
|
||||||
|
|
||||||
|
|
||||||
// return redirect()->route('hardware/bulkedit');
|
|
||||||
return redirect($bulk_back_url)->with('bulk_errors', array_unique($errors));
|
return redirect($bulk_back_url)->with('bulk_errors', array_unique($errors));
|
||||||
}
|
}
|
||||||
return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.update.success'));
|
return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.update.success'));
|
||||||
|
|
|
@ -9,7 +9,6 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Schema;
|
use Schema;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
// use App\Models\SnipeModel;
|
|
||||||
class CustomField extends Model
|
class CustomField extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
Loading…
Reference in a new issue