Merge branch 'develop' of github.com:snipe/snipe-it into develop

This commit is contained in:
snipe 2017-03-31 15:48:49 -07:00
commit 961c019554
13 changed files with 479 additions and 105 deletions

View file

@ -41,6 +41,7 @@ script:
# - ./vendor/bin/codecept run acceptance --env=testing-ci
- ./vendor/bin/codecept run functional --env=functional-travis
#script: ./vendor/bin/codecept run
- ./vendor/bin/codecept run api --env=testing-ci
after_success:
- codecov

View file

@ -1,4 +1,4 @@
FROM ubuntu:trusty
FROM debian:jessie-slim
MAINTAINER Brady Wetherington <uberbrady@gmail.com>
RUN apt-get update && apt-get install -y \
@ -13,7 +13,9 @@ patch \
curl \
vim \
git \
mysql-client
mysql-client \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN php5enmod mcrypt
RUN php5enmod gd
@ -55,7 +57,6 @@ RUN chown -R docker /var/www/html
RUN \
rm -r "/var/www/html/storage/private_uploads" && ln -fs "/var/lib/snipeit/data/private_uploads" "/var/www/html/storage/private_uploads" \
&& mkdir -p "/var/lib/snipeit/data/uploads/{assets,avatars,barcodes,models,suppliers}" \
&& rm -rf "/var/www/html/public/uploads" && ln -fs "/var/lib/snipeit/data/uploads" "/var/www/html/public/uploads" \
&& rm -r "/var/www/html/storage/app/backups" && ln -fs "/var/lib/snipeit/dumps" "/var/www/html/storage/app/backups"

View file

@ -117,6 +117,11 @@ class PaveIt extends Command
\DB::statement('drop table IF EXISTS manufacturers');
\DB::statement('drop table IF EXISTS models');
\DB::statement('drop table IF EXISTS migrations');
\DB::statement('drop table IF EXISTS oauth_access_tokens');
\DB::statement('drop table IF EXISTS oauth_auth_codes');
\DB::statement('drop table IF EXISTS oauth_clients');
\DB::statement('drop table IF EXISTS oauth_personal_access_clients');
\DB::statement('drop table IF EXISTS oauth_refresh_tokens');
\DB::statement('drop table IF EXISTS password_resets');
\DB::statement('drop table IF EXISTS requested_assets');
\DB::statement('drop table IF EXISTS requests');

View file

@ -287,23 +287,36 @@ class AssetsController extends Controller
if ($asset = Asset::find($id)) {
($request->has('model_id')) ?
$asset->model()->associate(AssetModel::find($request->get('model_id'))) : '';
($request->has('name')) ? $asset->name = $request->get('name') : '';
($request->has('serial')) ? $asset->serial = $request->get('serial') : '';
($request->has('model_id')) ? $asset->model_id = $request->get('model_id') : '';
($request->has('order_number')) ? $asset->order_number = $request->get('order_number') : '';
($request->has('notes')) ? $asset->notes = $request->get('notes') : '';
($request->has('asset_tag')) ? $asset->asset_tag = $request->input('asset_tag') : '';
($request->has('archived')) ? $asset->archived = $request->get('archived') : '';
($request->has('status_id')) ? $asset->status_id = $request->get('status_id') : '';
($request->has('warranty_months')) ? $asset->warranty_months = $request->get('warranty_months') : '';
($request->has('name')) ?
$asset->name = $request->get('name') : '';
($request->has('serial')) ?
$asset->serial = $request->get('serial') : '';
($request->has('model_id')) ?
$asset->model_id = $request->get('model_id') : '';
($request->has('order_number')) ?
$asset->order_number = $request->get('order_number') : '';
($request->has('notes')) ?
$asset->notes = $request->get('notes') : '';
($request->has('asset_tag')) ?
$asset->asset_tag = $request->get('asset_tag') : '';
($request->has('archived')) ?
$asset->archived = $request->get('archived') : '';
($request->has('status_id')) ?
$asset->status_id = $request->get('status_id') : '';
($request->has('warranty_months')) ?
$asset->warranty_months = $request->get('warranty_months') : '';
($request->has('purchase_cost')) ?
$asset->purchase_cost = Helper::ParseFloat($request->get('purchase_cost')) : '';
($request->has('purchase_date')) ? $asset->purchase_date = $request->get('purchase_date') : '';
($request->has('assigned_to')) ? $asset->assigned_to = $request->get('assigned_to') : '';
($request->has('supplier_id')) ? $asset->supplier_id = $request->get('supplier_id') : '';
($request->has('requestable')) ? $asset->name = $request->get('requestable') : '';
($request->has('archived')) ? $asset->name = $request->get('archived') : '';
($request->has('rtd_location_id')) ? $asset->name = $request->get('rtd_location_id') : '';
($request->has('purchase_date')) ?
$asset->purchase_date = $request->get('purchase_date') : '';
($request->has('assigned_to')) ?
$asset->assigned_to = $request->get('assigned_to') : '';
($request->has('supplier_id')) ?
$asset->supplier_id = $request->get('supplier_id') : '';
($request->has('requestable')) ?
$asset->requestable = $request->get('requestable') : '';
($request->has('rtd_location_id')) ?
$asset->rtd_location_id = $request->get('rtd_location_id') : '';
($request->has('company_id')) ?
$asset->company_id = Company::getIdForCurrentUser($request->get('company_id')) : '';
@ -335,8 +348,6 @@ class AssetsController extends Controller
}
return response()->json(Helper::formatStandardApiResponse('error', null, $asset->getErrors()), 200);
}
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 200);
}

View file

@ -135,7 +135,7 @@ class ComponentsController extends Controller
$component = Component::findOrFail($id);
$this->authorize('delete', $component);
$component->delete();
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/components/message.delete.success')));
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/components/message.delete.success')));
}
/**

View file

@ -41,7 +41,7 @@ class ViewAssetsController extends Controller
{
$user = User::with(
'assignedAssets.model',
'assets.model',
'consumables',
'accessories',
'licenses',

View file

@ -54,18 +54,18 @@ class Asset extends Depreciable
use ValidatingTrait, UniqueUndeletedTrait;
protected $rules = [
'name' => 'max:255|nullable',
'model_id' => 'required|integer|exists:models,id',
'status_id' => 'required|integer|exists:status_labels,id',
'company_id' => 'integer|nullable',
'warranty_months' => 'numeric|nullable',
'physical' => 'numeric|max:1|nullable',
'checkout_date' => 'date|max:10|min:10|nullable',
'checkin_date' => 'date|max:10|min:10|nullable',
'supplier_id' => 'numeric|nullable',
'asset_tag' => 'required|min:1|max:255|unique_undeleted',
'status' => 'integer',
'purchase_cost' => 'numeric|nullable',
'name' => 'max:255|nullable',
'model_id' => 'required|integer|exists:models,id',
'status_id' => 'required|integer|exists:status_labels,id',
'company_id' => 'integer|nullable',
'warranty_months' => 'numeric|nullable',
'physical' => 'numeric|max:1|nullable',
'checkout_date' => 'date|max:10|min:10|nullable',
'checkin_date' => 'date|max:10|min:10|nullable',
'supplier_id' => 'numeric|nullable',
'asset_tag' => 'required|min:1|max:255|unique_undeleted',
'status' => 'integer',
'purchase_cost' => 'numeric|nullable',
];
/**

View file

@ -34,7 +34,8 @@
"symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*",
"codeception/codeception": "2.2.9",
"squizlabs/php_codesniffer": "*"
"squizlabs/php_codesniffer": "*",
"laravel/tinker": "^1.0"
},
"autoload": {
"classmap": [

306
composer.lock generated
View file

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "c083ff96bd4f38110f66aa5d92da21c5",
"content-hash": "e59a7dbb0757b4c418fca159cfb22fac",
"hash": "01797ce4699addd08573664ba2e040f7",
"content-hash": "5c3055e9052b11b2adc3204a2a81a935",
"packages": [
{
"name": "aws/aws-sdk-php",
@ -4074,6 +4074,39 @@
],
"time": "2017-02-04 02:04:21"
},
{
"name": "dnoegel/php-xdg-base-dir",
"version": "0.1",
"source": {
"type": "git",
"url": "https://github.com/dnoegel/php-xdg-base-dir.git",
"reference": "265b8593498b997dc2d31e75b89f053b5cc9621a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dnoegel/php-xdg-base-dir/zipball/265b8593498b997dc2d31e75b89f053b5cc9621a",
"reference": "265b8593498b997dc2d31e75b89f053b5cc9621a",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"require-dev": {
"phpunit/phpunit": "@stable"
},
"type": "project",
"autoload": {
"psr-4": {
"XdgBaseDir\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "implementation of xdg base directory specification for php",
"time": "2014-10-24 07:27:01"
},
{
"name": "doctrine/instantiator",
"version": "1.0.5",
@ -4225,6 +4258,151 @@
],
"time": "2016-04-29 12:21:54"
},
{
"name": "jakub-onderka/php-console-color",
"version": "0.1",
"source": {
"type": "git",
"url": "https://github.com/JakubOnderka/PHP-Console-Color.git",
"reference": "e0b393dacf7703fc36a4efc3df1435485197e6c1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Color/zipball/e0b393dacf7703fc36a4efc3df1435485197e6c1",
"reference": "e0b393dacf7703fc36a4efc3df1435485197e6c1",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"require-dev": {
"jakub-onderka/php-code-style": "1.0",
"jakub-onderka/php-parallel-lint": "0.*",
"jakub-onderka/php-var-dump-check": "0.*",
"phpunit/phpunit": "3.7.*",
"squizlabs/php_codesniffer": "1.*"
},
"type": "library",
"autoload": {
"psr-0": {
"JakubOnderka\\PhpConsoleColor": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Jakub Onderka",
"email": "jakub.onderka@gmail.com",
"homepage": "http://www.acci.cz"
}
],
"time": "2014-04-08 15:00:19"
},
{
"name": "jakub-onderka/php-console-highlighter",
"version": "v0.3.2",
"source": {
"type": "git",
"url": "https://github.com/JakubOnderka/PHP-Console-Highlighter.git",
"reference": "7daa75df45242c8d5b75a22c00a201e7954e4fb5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Highlighter/zipball/7daa75df45242c8d5b75a22c00a201e7954e4fb5",
"reference": "7daa75df45242c8d5b75a22c00a201e7954e4fb5",
"shasum": ""
},
"require": {
"jakub-onderka/php-console-color": "~0.1",
"php": ">=5.3.0"
},
"require-dev": {
"jakub-onderka/php-code-style": "~1.0",
"jakub-onderka/php-parallel-lint": "~0.5",
"jakub-onderka/php-var-dump-check": "~0.1",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~1.5"
},
"type": "library",
"autoload": {
"psr-0": {
"JakubOnderka\\PhpConsoleHighlighter": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jakub Onderka",
"email": "acci@acci.cz",
"homepage": "http://www.acci.cz/"
}
],
"time": "2015-04-20 18:58:01"
},
{
"name": "laravel/tinker",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/tinker.git",
"reference": "3d5b675b55b24ccbf86395964042dbe061d5a965"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/tinker/zipball/3d5b675b55b24ccbf86395964042dbe061d5a965",
"reference": "3d5b675b55b24ccbf86395964042dbe061d5a965",
"shasum": ""
},
"require": {
"illuminate/console": "~5.1",
"illuminate/contracts": "~5.1",
"illuminate/support": "~5.1",
"php": ">=5.5.9",
"psy/psysh": "0.7.*|0.8.*",
"symfony/var-dumper": "~3.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0|~5.0"
},
"suggest": {
"illuminate/database": "The Illuminate Database package (~5.1)."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Laravel\\Tinker\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "Powerful REPL for the Laravel framework.",
"keywords": [
"REPL",
"Tinker",
"laravel",
"psysh"
],
"time": "2016-12-30 18:13:17"
},
{
"name": "myclabs/deep-copy",
"version": "1.6.0",
@ -4267,6 +4445,57 @@
],
"time": "2017-01-26 22:05:40"
},
{
"name": "nikic/php-parser",
"version": "v3.0.5",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "2b9e2f71b722f7c53918ab0c25f7646c2013f17d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/2b9e2f71b722f7c53918ab0c25f7646c2013f17d",
"reference": "2b9e2f71b722f7c53918ab0c25f7646c2013f17d",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=5.5"
},
"require-dev": {
"phpunit/phpunit": "~4.0|~5.0"
},
"bin": [
"bin/php-parse"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"PhpParser\\": "lib/PhpParser"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Nikita Popov"
}
],
"description": "A PHP parser written in PHP",
"keywords": [
"parser",
"php"
],
"time": "2017-03-05 18:23:57"
},
{
"name": "phpdocumentor/reflection-common",
"version": "1.0",
@ -4866,6 +5095,79 @@
],
"time": "2016-12-08 20:27:08"
},
{
"name": "psy/psysh",
"version": "v0.8.2",
"source": {
"type": "git",
"url": "https://github.com/bobthecow/psysh.git",
"reference": "97113db4107a4126bef933b60fea6dbc9f615d41"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/97113db4107a4126bef933b60fea6dbc9f615d41",
"reference": "97113db4107a4126bef933b60fea6dbc9f615d41",
"shasum": ""
},
"require": {
"dnoegel/php-xdg-base-dir": "0.1",
"jakub-onderka/php-console-highlighter": "0.3.*",
"nikic/php-parser": "~1.3|~2.0|~3.0",
"php": ">=5.3.9",
"symfony/console": "~2.3.10|^2.4.2|~3.0",
"symfony/var-dumper": "~2.7|~3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~1.11",
"hoa/console": "~3.16|~1.14",
"phpunit/phpunit": "~4.4|~5.0",
"symfony/finder": "~2.1|~3.0"
},
"suggest": {
"ext-pcntl": "Enabling the PCNTL extension makes PsySH a lot happier :)",
"ext-pdo-sqlite": "The doc command requires SQLite to work.",
"ext-posix": "If you have PCNTL, you'll want the POSIX extension as well.",
"ext-readline": "Enables support for arrow-key history navigation, and showing and manipulating command history.",
"hoa/console": "A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit."
},
"bin": [
"bin/psysh"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-develop": "0.9.x-dev"
}
},
"autoload": {
"files": [
"src/Psy/functions.php"
],
"psr-4": {
"Psy\\": "src/Psy/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Justin Hileman",
"email": "justin@justinhileman.info",
"homepage": "http://justinhileman.com"
}
],
"description": "An interactive shell for modern PHP.",
"homepage": "http://psysh.org",
"keywords": [
"REPL",
"console",
"interactive",
"shell"
],
"time": "2017-03-01 00:13:29"
},
{
"name": "sebastian/code-unit-reverse-lookup",
"version": "1.0.1",

View file

@ -219,6 +219,7 @@ return [
Fideloper\Proxy\TrustedProxyServiceProvider::class,
PragmaRX\Google2FA\Vendor\Laravel\ServiceProvider::class,
Laravel\Passport\PassportServiceProvider::class,
Laravel\Tinker\TinkerServiceProvider::class,
/*

View file

@ -18,7 +18,7 @@ else
fi
# create data directories
for dir in 'data/private_uploads' 'data/uploads' 'data/uploads/avatars' 'data/uploads/models' 'data/uploads/suppliers' 'dumps'; do
for dir in 'data/private_uploads' 'data/uploads' 'data/uploads/avatars' 'data/uploads/barcodes' 'data/uploads/models' 'data/uploads/suppliers' 'dumps'; do
mkdir -p "/var/lib/snipeit/$dir"
done

File diff suppressed because one or more lines are too long

View file

@ -121,7 +121,7 @@ class ApiAssetsCest
// setup
$data = [
'asset_tag' => $temp_asset->tag,
'asset_tag' => $temp_asset->asset_tag,
'assigned_to' => $temp_asset->assigned_to,
'company_id' => $temp_asset->company->id,
'image' => $temp_asset->image,
@ -148,14 +148,14 @@ class ApiAssetsCest
{
$I->wantTo('Update an asset with PATCH');
// create and store an asset
// create
$asset = factory(\App\Models\Asset::class, 'asset')->create();
$I->assertInstanceOf(\App\Models\Asset::class, $asset);
// create a temporary asset to grab new data
$temp_asset = factory(\App\Models\Asset::class, 'asset')->make();
$data = [
'asset_tag' => $temp_asset->tag,
'asset_tag' => $temp_asset->asset_tag,
'assigned_to' => $temp_asset->assigned_to,
'company_id' => $temp_asset->company->id,
'image' => $temp_asset->image,
@ -171,7 +171,6 @@ class ApiAssetsCest
'warranty_months' => $temp_asset->warranty_months,
];
// the asset name should be different
$I->assertNotEquals($asset->name, $data['name']);
// update
@ -182,24 +181,19 @@ class ApiAssetsCest
$response = json_decode($I->grabResponse());
$I->assertEquals('success', $response->status);
$I->assertEquals(trans('admin/hardware/message.update.success'), $response->messages);
$I->assertEquals($asset->id, $response->payload->id);
$I->assertEquals($data['name'], $response->payload->name);
$I->assertEquals($data['asset_tag'], $response->payload->asset_tag);
$I->assertEquals($data['model_id'], $response->payload->model_id);
// dd($response, $asset->getAttributes());
$I->assertEquals($asset->id, $response->payload->id); // asset id does not change
$I->assertEquals($temp_asset->asset_tag, $response->payload->asset_tag); // asset tag updated
$I->assertEquals($temp_asset->name, $response->payload->name); // asset name updated
$I->assertEquals($temp_asset->rtd_location_id, $response->payload->rtd_location_id); // asset rtd_location_id updated
// verify
// $scenario->incomplete('[BadMethodCallException] Call to undefined method Illuminate\Database\Query\Builder::detail() 🤔');
$I->sendGET('/hardware/' . $asset->id);
$I->seeResponseIsJson();
$I->seeResponseCodeIs(200);
$I->seeResponseContainsJson([
'id' => (int) $asset->id,
'name' => e($temp_asset->name), // TODO: name should change
'asset_tag' => e($temp_asset->asset_tag), // TODO: asset_tag should change
'name' => e($temp_asset->name),
'asset_tag' => e($temp_asset->asset_tag),
'serial' => e($temp_asset->serial),
'model' => ($temp_asset->model) ? [
'id' => (int) $temp_asset->model->id,
@ -220,17 +214,17 @@ class ApiAssetsCest
] : null,
'notes' => e($temp_asset->notes),
'order_number' => e($asset->order_number),
'company' => ($temp_asset->company) ? [
'company' => ($asset->company) ? [
'id' => (int) $temp_asset->company->id,
'name'=> e($temp_asset->company->name)
] : null,
'location' => ($asset->assetLoc) ? [
'id' => (int) $asset->assetLoc->id,
'name'=> e($asset->assetLoc->name)
'location' => ($temp_asset->assetLoc) ? [
'id' => (int) $temp_asset->assetLoc->id,
'name'=> e($temp_asset->assetLoc->name)
] : null,
'rtd_location' => ($asset->defaultLoc) ? [
'id' => (int) $asset->defaultLoc->id,
'name'=> e($asset->defaultLoc->name)
'rtd_location' => ($temp_asset->defaultLoc) ? [
'id' => (int) $temp_asset->defaultLoc->id,
'name'=> e($temp_asset->defaultLoc->name)
] : null,
'image' => ($asset->getImageUrl()) ? $asset->getImageUrl() : null,
'assigned_to' => ($temp_asset->assigneduser) ? [
@ -284,11 +278,29 @@ class ApiAssetsCest
$asset = factory(\App\Models\Asset::class, 'asset')->create();
$I->assertInstanceOf(\App\Models\Asset::class, $asset);
$company = \App\Models\Company::inRandomOrder()->first();
$temp_asset_tag = $this->faker->uuid;
$temp_asset = factory(\App\Models\Asset::class, 'asset')->make([
'asset_tag' => $temp_asset_tag,
]);
$I->assertNotNull($temp_asset->asset_tag);
$I->assertEquals($temp_asset_tag, $temp_asset->asset_tag);
$data = [
'name' => $this->faker->sentence(3),
'company_id' => $company->id,
'asset_tag' => $temp_asset->asset_tag,
'assigned_to' => $temp_asset->assigned_to,
'company_id' => $temp_asset->company->id,
'image' => $temp_asset->image,
'model_id' => $temp_asset->model_id,
'name' => $temp_asset->name,
'notes' => $temp_asset->notes,
'purchase_cost' => $temp_asset->purchase_cost,
'purchase_date' => $temp_asset->purchase_date->format('Y-m-d'),
'rtd_location_id' => $temp_asset->rtd_location_id,
'serial' => $temp_asset->serial,
'status_id' => $temp_asset->status_id,
'supplier_id' => $temp_asset->supplier_id,
'warranty_months' => $temp_asset->warranty_months,
];
$I->assertNotEquals($asset->name, $data['name']);
@ -301,7 +313,10 @@ class ApiAssetsCest
$response = json_decode($I->grabResponse());
$I->assertEquals('success', $response->status);
$I->assertEquals(trans('admin/hardware/message.update.success'), $response->messages);
$I->assertEquals($asset->id, $response->payload->id);
$I->assertEquals($asset->id, $response->payload->id); // asset id does not change
$I->assertEquals($temp_asset->asset_tag, $response->payload->asset_tag); // asset tag updated
$I->assertEquals($temp_asset->name, $response->payload->name); // asset name updated
$I->assertEquals($temp_asset->rtd_location_id, $response->payload->rtd_location_id); // asset rtd_location_id updated
// verify
$I->sendGET('/hardware/' . $asset->id);
@ -309,46 +324,46 @@ class ApiAssetsCest
$I->seeResponseCodeIs(200);
$I->seeResponseContainsJson([
'id' => (int) $asset->id,
'name' => e($data['name']),
'asset_tag' => e($asset->asset_tag),
'serial' => e($asset->serial),
'model' => ($asset->model) ? [
'id' => (int) $asset->model->id,
'name'=> e($asset->model->name)
'name' => e($temp_asset->name),
'asset_tag' => e($temp_asset->asset_tag),
'serial' => e($temp_asset->serial),
'model' => ($temp_asset->model) ? [
'id' => (int) $temp_asset->model->id,
'name'=> e($temp_asset->model->name)
] : null,
'model_number' => ($asset->model) ? e($asset->model->model_number) : null,
'status_label' => ($asset->assetstatus) ? [
'id' => (int) $asset->assetstatus->id,
'name'=> e($asset->assetstatus->name)
'model_number' => ($temp_asset->model) ? e($temp_asset->model->model_number) : null,
'status_label' => ($temp_asset->assetstatus) ? [
'id' => (int) $temp_asset->assetstatus->id,
'name'=> e($temp_asset->assetstatus->name)
] : null,
'category' => ($asset->model->category) ? [
'id' => (int) $asset->model->category->id,
'name'=> e($asset->model->category->name)
'category' => ($temp_asset->model->category) ? [
'id' => (int) $temp_asset->model->category->id,
'name'=> e($temp_asset->model->category->name)
] : null,
'manufacturer' => ($asset->model->manufacturer) ? [
'id' => (int) $asset->model->manufacturer->id,
'name'=> e($asset->model->manufacturer->name)
'manufacturer' => ($temp_asset->model->manufacturer) ? [
'id' => (int) $temp_asset->model->manufacturer->id,
'name'=> e($temp_asset->model->manufacturer->name)
] : null,
'notes' => e($asset->notes),
'notes' => e($temp_asset->notes),
'order_number' => e($asset->order_number),
'company' => ($asset->company) ? [
'id' => (int) $data['company_id'],
'name'=> e($company->name)
'id' => (int) $temp_asset->company->id,
'name'=> e($temp_asset->company->name)
] : null,
'location' => ($asset->assetLoc) ? [
'id' => (int) $asset->assetLoc->id,
'name'=> e($asset->assetLoc->name)
'location' => ($temp_asset->assetLoc) ? [
'id' => (int) $temp_asset->assetLoc->id,
'name'=> e($temp_asset->assetLoc->name)
] : null,
'rtd_location' => ($asset->defaultLoc) ? [
'id' => (int) $asset->defaultLoc->id,
'name'=> e($asset->defaultLoc->name)
'rtd_location' => ($temp_asset->defaultLoc) ? [
'id' => (int) $temp_asset->defaultLoc->id,
'name'=> e($temp_asset->defaultLoc->name)
] : null,
'image' => ($asset->getImageUrl()) ? $asset->getImageUrl() : null,
'assigned_to' => ($asset->assigneduser) ? [
'id' => (int) $asset->assigneduser->id,
'name' => e($asset->assigneduser->getFullNameAttribute()),
'first_name'=> e($asset->assigneduser->first_name),
'last_name'=> e($asset->assigneduser->last_name)
'assigned_to' => ($temp_asset->assigneduser) ? [
'id' => (int) $temp_asset->assigneduser->id,
'name' => e($temp_asset->assigneduser->getFullNameAttribute()),
'first_name'=> e($temp_asset->assigneduser->first_name),
'last_name'=> e($temp_asset->assigneduser->last_name)
] : null,
'warranty' => ($asset->warranty_months > 0) ? e($asset->warranty_months . ' ' . trans('admin/hardware/form.months')) : null,
'warranty_expires' => ($asset->warranty_months > 0) ? [
@ -376,7 +391,7 @@ class ApiAssetsCest
// 'formatted' => $asset->created_at->format('Y-m-d'),
// ] : null,
// 'purchase_cost' => (float) $asset->purchase_cost,
'user_can_checkout' => (bool) $asset->availableForCheckout(),
'user_can_checkout' => (bool) $temp_asset->availableForCheckout(),
'available_actions' => [
'checkout' => (bool) Gate::allows('checkout', Asset::class),
'checkin' => (bool) Gate::allows('checkin', Asset::class),