Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:snipe/snipe-it into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Jul 26, 2016
2 parents 261d2f1 + e0938cf commit ad531d6
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/AccessoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ public function postCheckin(Request $request, $accessoryUserId = null, $backto =
**/
public function getDatatable(Request $request)
{
$accessories = Accessory::select('accessories.*')->with('category', 'company')
$accessories = Company::scopeCompanyables(Accessory::select('accessories.*')->with('category', 'company'))
->whereNull('accessories.deleted_at');

if (Input::has('search')) {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ public function getDatatable($status = null)
{


$assets = Asset::select('assets.*')->with('model', 'assigneduser', 'assigneduser.userloc', 'assetstatus', 'defaultLoc', 'assetlog', 'model', 'model.category', 'model.manufacturer', 'model.fieldset', 'assetstatus', 'assetloc', 'company')
$assets = Company::scopeCompanyables(Asset::select('assets.*'))->with('model', 'assigneduser', 'assigneduser.userloc', 'assetstatus', 'defaultLoc', 'assetlog', 'model', 'model.category', 'model.manufacturer', 'model.fieldset', 'assetstatus', 'assetloc', 'company')
->Hardware();

if (Input::has('search')) {
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/ComponentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ public function postCheckout(Request $request, $componentId)
**/
public function getDatatable()
{
$components = Component::select('components.*')->whereNull('components.deleted_at')
->with('company', 'location', 'category');
$components = Company::scopeCompanyables(Component::select('components.*')->whereNull('components.deleted_at')
->with('company', 'location', 'category'));

if (Input::has('search')) {
$components = $components->TextSearch(Input::get('search'));
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/ConsumablesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ public function postCheckout($consumableId)
*/
public function getDatatable()
{
$consumables = Consumable::select('consumables.*')->whereNull('consumables.deleted_at')
->with('company', 'location', 'category', 'users');
$consumables = Company::scopeCompanyables(Consumable::select('consumables.*')->whereNull('consumables.deleted_at')
->with('company', 'location', 'category', 'users'));

if (Input::has('search')) {
$consumables = $consumables->TextSearch(e(Input::get('search')));
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/LicensesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ public function displayFile($licenseId = null, $fileId = null)
*/
public function getDatatable()
{
$licenses = License::with('company');
$licenses = Company::scopeCompanyables(License::with('company'));

if (Input::has('search')) {
$licenses = $licenses->TextSearch(Input::get('search'));
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public function adminuser()
public static function assetcount()
{

return Asset::where('physical', '=', '1')
return Company::scopeCompanyables(Asset::where('physical', '=', '1'))
->whereNull('deleted_at', 'and')
->count();
}
Expand Down
8 changes: 2 additions & 6 deletions app/Models/Company.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ private static function scopeCompanyablesDirectly($query, $column = 'company_id'
$company_id = null;
}

if ($company_id == null) {
return $query;
} else {
return $query->where($column, '=', $company_id);
}
return $query->where($column, '=', $company_id);
}

public static function getSelectList()
Expand Down Expand Up @@ -141,7 +137,7 @@ public static function scopeCompanyableChildren(array $companyable_names, $query
{
if (count($companyable_names) == 0) {
throw new Exception('No Companyable Children to scope');
} elseif (!static::isFullMultipleCompanySupportEnabled()) {
} elseif (!static::isFullMultipleCompanySupportEnabled() || (Auth::check() && Auth::user()->isSuperUser())) {
return $query;
} else {
$f = function ($q) {
Expand Down

0 comments on commit ad531d6

Please sign in to comment.