mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Removed unneeded relationships
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
097821b818
commit
1fa624420e
|
@ -8,6 +8,7 @@ use App\Models\AssetModel;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Models\CustomField;
|
||||||
use App\Notifications\RequestAssetCancelation;
|
use App\Notifications\RequestAssetCancelation;
|
||||||
use App\Notifications\RequestAssetNotification;
|
use App\Notifications\RequestAssetNotification;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
@ -29,23 +30,28 @@ class ViewAssetsController extends Controller
|
||||||
public function getIndex()
|
public function getIndex()
|
||||||
{
|
{
|
||||||
$user = User::with(
|
$user = User::with(
|
||||||
|
'assets',
|
||||||
'assets.model',
|
'assets.model',
|
||||||
|
'assets.model.fieldset.fields',
|
||||||
'consumables',
|
'consumables',
|
||||||
'accessories',
|
'accessories',
|
||||||
'licenses',
|
'licenses',
|
||||||
'userloc',
|
)->find(Auth::user()->id);
|
||||||
'userlog'
|
|
||||||
)->withTrashed()->find(Auth::user()->id);
|
|
||||||
|
|
||||||
$userlog = $user->userlog->load('item', 'user', 'target');
|
|
||||||
|
foreach ($user->assets as $asset) {
|
||||||
|
foreach ($asset->model->fieldset->fields as $field) {
|
||||||
|
$field_array[$field->db_column] = $field->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
array_unique($field_array);
|
||||||
|
|
||||||
if (isset($user->id)) {
|
if (isset($user->id)) {
|
||||||
return view('account/view-assets', compact('user', 'userlog'))
|
return view('account/view-assets', compact('user', 'field_array' ))
|
||||||
->with('settings', Setting::getSettings());
|
->with('settings', Setting::getSettings());
|
||||||
} else {
|
|
||||||
// Redirect to the user management page
|
|
||||||
return redirect()->route('users.index')->with('error', trans('admin/users/message.user_not_found', compact('id')));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect to the user management page
|
// Redirect to the user management page
|
||||||
return redirect()->route('users.index')
|
return redirect()->route('users.index')
|
||||||
->with('error', trans('admin/users/message.user_not_found', $user->id));
|
->with('error', trans('admin/users/message.user_not_found', $user->id));
|
||||||
|
|
Loading…
Reference in a new issue