3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-05-13 10:07:31 +00:00

Company to logs (#2717)

* Fix the actionlog/companyables problem by adding a company_id to all actionlogs and scoping directly on that.  Works around bugs in laravel where trying to hunt down the polymorphic relationship would lead to an infinite loop

* Scope companyables in getactivityreport.  Also eager load.

* Improve reportscontroller, work on seeder to test this.

* Only show company users in checkout dialogs

* If no admin associated with log, it might be a request.  Leave blank instead of saying deleted admin

* When injecting company_id, use target instead of user if user is a superadmin

* Build up the seeder to generate users, companies, and logs.

* Eager load the log, don't scope the users log because the log should already include things only related to the user.
This commit is contained in:
Daniel Meltzer
2016-09-30 00:20:49 -05:00
committed by snipe
parent 7ca7877740
commit 2a95a95e00
13 changed files with 231 additions and 37 deletions

View File

@ -39,7 +39,16 @@ class ViewAssetsController extends Controller
public function getIndex()
{
$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find(Auth::user()->id);
$user = User::with(
'assets',
'assets.model',
'consumables',
'accessories',
'licenses',
'userloc',
'userlog'
)->withTrashed()->find(Auth::user()->id);
$userlog = $user->userlog->load('item', 'user', 'target');
@ -76,7 +85,7 @@ class ViewAssetsController extends Controller
{
$item = null;
$fullItemType = 'App\\Models\\' . studly_case($itemType);
if($itemType == "asset_model") {
if ($itemType == "asset_model") {
$itemType = "model";
}
$item = call_user_func(array($fullItemType, 'find'), $itemId);