Skip to content

A free open source IT asset/license management system

Merge branch 'master' into rcs/merge_master_into_develop_for_rc_8

snipe9aac1cbba46b
diff --cc .all-contributorsrc
index 10f450be42,f953f72768..bb0c8ce07c
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@@ -2578,31 -2542,31 +2578,49 @@@
]
},
{
- "login": "savornicesei",
- "name": "Simona Avornicesei",
- "avatar_url": "https://avatars.githubusercontent.com/u/917232?v=4",
- "profile": "http://www.avornicesei.com",
+ "login": "insert-waffle",
+ "name": "waffle",
+ "avatar_url": "https://avatars.githubusercontent.com/u/9415391?v=4",
+ "profile": "https://ditisjens.be/",
"contributions": [
- "test"
+ "code"
+ ]
+ },
+ {
+ "login": "QveenSi",
+ "name": "Yevhenii Huzii",
+ "avatar_url": "https://avatars.githubusercontent.com/u/19945501?v=4",
+ "profile": "https://github.com/QveenSi",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "veenone",
+ "name": "Achmad Fienan Rahardianto",
+ "avatar_url": "https://avatars.githubusercontent.com/u/3839381?v=4",
+ "profile": "https://github.com/veenone",
+ "contributions": [
+ "code"
]
+ },
+ {
+ "login": "QveenSi",
+ "name": "Yevhenii Huzii",
+ "avatar_url": "https://avatars.githubusercontent.com/u/19945501?v=4",
+ "profile": "https://github.com/QveenSi",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "chrisweirich",
+ "name": "Christian Weirich",
+ "avatar_url": "https://avatars.githubusercontent.com/u/97299851?v=4",
+ "profile": "https://github.com/chrisweirich",
+ "contributions": [
+ "code"
+ ]
}
]
}
diff --cc app/Console/Commands/MoveUploadsToNewDisk.php
index 9de6781fb6,700a02d254..6ebdd08168
--- a/app/Console/Commands/MoveUploadsToNewDisk.php
+++ b/app/Console/Commands/MoveUploadsToNewDisk.php
@@@ -77,90 -79,105 +77,99 @@@ class MoveUploadsToNewDisk extends Comm
\Log::debug($e);
$this->error($e);
}
-
}
-
}
- $logos = glob('public/uploads/setting*.*');
- $this->info('- There are ' . count($logos) . ' files that might be logos.');
+ $logos = glob("public/uploads/setting*.*");
+ $this->info("- There are ".count($logos).' files that might be logos.');
$type_count = 0;
foreach ($logos as $logo) {
$this->info($logo);
$type_count++;
$filename = basename($logo);
- Storage::disk('public')->put('uploads/'.$filename, file_get_contents($logo));
- $this->info($type_count.'. LOGO: '.$filename.' was copied to '.env('PUBLIC_AWS_URL').'/uploads/'.$filename);
+ Storage::disk('public')->put('uploads/' . $filename, file_get_contents($logo));
+ $this->info($type_count . '. LOGO: ' . $filename . ' was copied to ' . env('PUBLIC_AWS_URL') . '/uploads/' . $filename);
}
+ $private_uploads['assets'] = glob('storage/private_uploads/assets'."/*.*");
+ $private_uploads['signatures'] = glob('storage/private_uploads/signatures'."/*.*");
+ $private_uploads['audits'] = glob('storage/private_uploads/audits'."/*.*");
+ $private_uploads['assetmodels'] = glob('storage/private_uploads/assetmodels'."/*.*");
+ $private_uploads['imports'] = glob('storage/private_uploads/imports'."/*.*");
+ $private_uploads['licenses'] = glob('storage/private_uploads/licenses'."/*.*");
+ $private_uploads['users'] = glob('storage/private_uploads/users'."/*.*");
+ $private_uploads['backups'] = glob('storage/private_uploads/backups'."/*.*");
+
-
- foreach($private_uploads as $private_type => $private_upload)
- {
- $this->info("- There are ".count($private_upload).' PRIVATE '.$private_type.' files.');
-
- $type_count = 0;
- for ($x = 0; $x < count($private_upload); $x++) {
- $type_count++;
- $filename = basename($private_upload[$x]);
-
- try {
- Storage::put($private_type.'/'.$filename, file_get_contents($private_upload[$i]));
- $new_url = Storage::url($private_type.'/'.$filename, $filename);
- $this->info($type_count.'. PRIVATE: '.$filename.' was copied to '.$new_url);
-
- } catch (\Exception $e) {
- \Log::debug($e);
- $this->error($e);
+ $private_uploads['assets'] = glob('storage/private_uploads/assets' . '/*.*');
+ $private_uploads['signatures'] = glob('storage/private_uploads/signatures' . '/*.*');
+ $private_uploads['audits'] = glob('storage/private_uploads/audits' . '/*.*');
+ $private_uploads['assetmodels'] = glob('storage/private_uploads/assetmodels' . '/*.*');
+ $private_uploads['imports'] = glob('storage/private_uploads/imports' . '/*.*');
+ $private_uploads['licenses'] = glob('storage/private_uploads/licenses' . '/*.*');
+ $private_uploads['users'] = glob('storage/private_uploads/users' . '/*.*');
+ $private_uploads['backups'] = glob('storage/private_uploads/users' . '/*.*');
+
+ foreach ($private_uploads as $private_type => $private_upload) {
+ {
+ $this->info('- There are ' . count($private_upload) . ' PRIVATE ' . $private_type . ' files.');
+
+ $type_count = 0;
+ for ($x = 0; $x < count($private_upload); $x++) {
+ $type_count++;
+ $filename = basename($private_upload[$x]);
+
+ try {
+ Storage::put($private_type . '/' . $filename, file_get_contents($private_upload[$i]));
+ $new_url = Storage::url($private_type . '/' . $filename, $filename);
+ $this->info($type_count . '. PRIVATE: ' . $filename . ' was copied to ' . $new_url);
+ } catch (\Exception $e) {
+ \Log::debug($e);
+ $this->error($e);
+ }
}
-
}
- }
-
-
- if ($delete_local=='true') {
- $public_delete_count = 0;
- $private_delete_count = 0;
- $this->info("\n\n");
- $this->error('!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
- $this->warn("\nTHIS WILL DELETE ALL OF YOUR LOCAL UPLOADED FILES. \n\nThis cannot be undone, so you should take a backup of your system before you proceed.\n");
- $this->error('!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
-
- if ($this->confirm("Do you wish to continue?")) {
-
- foreach($public_uploads as $public_type => $public_upload) {
-
- for ($i = 0; $i < count($public_upload); $i++) {
- $filename = $public_upload[$i];
- try {
- unlink($filename);
- $public_delete_count++;
- } catch (\Exception $e) {
- \Log::debug($e);
- $this->error($e);
+ if ($delete_local == 'true') {
+ $public_delete_count = 0;
+ $private_delete_count = 0;
+
+ $this->info("\n\n");
+ $this->error('!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
+ $this->warn("\nTHIS WILL DELETE ALL OF YOUR LOCAL UPLOADED FILES. \n\nThis cannot be undone, so you should take a backup of your system before you proceed.\n");
+ $this->error('!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
+
+ if ($this->confirm('Do you wish to continue?')) {
+ foreach ($public_uploads as $public_type => $public_upload) {
+ for ($i = 0; $i < count($public_upload); $i++) {
+ $filename = $public_upload[$i];
+ try {
+ unlink($filename);
+ $public_delete_count++;
+ } catch (\Exception $e) {
+ \Log::debug($e);
+ $this->error($e);
+ }
}
-
}
- }
- foreach($private_uploads as $private_type => $private_upload)
- {
-
- for ($i = 0; $i < count($private_upload); $i++) {
- $filename = $private_upload[$i];
- try {
- unlink($filename);
- $private_delete_count++;
- } catch (\Exception $e) {
- \Log::debug($e);
- $this->error($e);
+ foreach ($private_uploads as $private_type => $private_upload) {
+ for ($i = 0; $i < count($private_upload); $i++) {
+ $filename = $private_upload[$i];
+ try {
+ unlink($filename);
+ $private_delete_count++;
+ } catch (\Exception $e) {
+ \Log::debug($e);
+ $this->error($e);
+ }
}
-
}
- }
- $this->info($public_delete_count." PUBLIC local files and ".$private_delete_count." PRIVATE local files were deleted from your filesystem.");
+ $this->info($public_delete_count . ' PUBLIC local files and ' . $private_delete_count . ' PRIVATE local files were deleted from your filesystem.');
+ }
}
}
-
-
-
-
}
}
diff --cc app/Http/Controllers/Api/AssetsController.php
index 13b745cdff,e8d805ea25..05c81b3cf5
--- a/app/Http/Controllers/Api/AssetsController.php
+++ b/app/Http/Controllers/Api/AssetsController.php
@@@ -786,9 -788,12 +786,12 @@@ class AssetsController extends Controll
$error_payload['target_type'] = 'user';
}
+ if ($request->filled('status_id')) {
+ $asset->status_id = $request->get('status_id');
+ }
- if (!isset($target)) {
+ if (! isset($target)) {
return response()->json(Helper::formatStandardApiResponse('error', $error_payload, 'Checkout target for asset '.e($asset->asset_tag).' is invalid - '.$error_payload['target_type'].' does not exist.'));
}
diff --cc app/Http/Controllers/Api/LicensesController.php
index 5a4c7d90d3,fcdfea5a13..ad0055c223
--- a/app/Http/Controllers/Api/LicensesController.php
+++ b/app/Http/Controllers/Api/LicensesController.php
@@@ -26,10 -26,11 +26,11 @@@ class LicensesController extends Contro
public function index(Request $request)
{
$this->authorize('view', License::class);
- $licenses = Company::scopeCompanyables(License::with('company', 'manufacturer', 'supplier', 'category')->withCount('freeSeats as free_seats_count'));
+ $licenses = Company::scopeCompanyables(License::with('company', 'manufacturer', 'supplier','category')->withCount('freeSeats as free_seats_count'));
+
if ($request->filled('company_id')) {
- $licenses->where('company_id','=',$request->input('company_id'));
+ $licenses->where('company_id', '=', $request->input('company_id'));
}
if ($request->filled('name')) {
@@@ -147,12 -139,18 +148,13 @@@
break;
}
-
-
$total = $licenses->count();
- $licenses = $licenses->skip($offset)->take($limit)->get();
+ $licenses = $licenses->skip($offset)->take($limit)->get();
return (new LicensesTransformer)->transformLicenses($licenses, $total);
+
}
-
-
-
/**
* Store a newly created resource in storage.
*
diff --cc app/Http/Controllers/Assets/AssetCheckinController.php
index 3ebd777865,913bf4bcf6..8acc0a7b62
--- a/app/Http/Controllers/Assets/AssetCheckinController.php
+++ b/app/Http/Controllers/Assets/AssetCheckinController.php
@@@ -101,9 -99,10 +101,10 @@@ class AssetCheckinController extends Co
\Log::debug('After Location ID: '.$asset->location_id);
\Log::debug('After RTD Location ID: '.$asset->rtd_location_id);
+
if ($request->filled('location_id')) {
\Log::debug('NEW Location ID: '.$request->get('location_id'));
- $asset->location_id = e($request->get('location_id'));
+ $asset->location_id = e($request->get('location_id'));
}
$checkin_at = date('Y-m-d H:i:s');
diff --cc app/Http/Controllers/Users/BulkUsersController.php
index 43e1cfa0f4,5069b4a38a..007bb3763d
--- a/app/Http/Controllers/Users/BulkUsersController.php
+++ b/app/Http/Controllers/Users/BulkUsersController.php
@@@ -51,9 -55,10 +51,9 @@@ class BulkUsersController extends Contr
});
}
}
-
return redirect()->back()->with('success', trans('admin/users/message.password_resets_sent'));
+
}
-
}
return redirect()->back()->with('error', 'No users selected');
@@@ -97,13 -103,12 +97,12 @@@
if (array_search($request->input('manager_id'), $user_raw_array)) {
$manager_conflict = true;
$return_array = [
- 'warning' => trans('admin/users/message.bulk_manager_warn')
+ 'warning' => trans('admin/users/message.bulk_manager_warn'),
];
}
- if (!$manager_conflict) {
+ if (! $manager_conflict) {
$this->conditionallyAddItem('manager_id');
}
-
// Save the updated info
User::whereIn('id', $user_raw_array)
->where('id', '!=', Auth::id())->update($this->update_array);
diff --cc app/Http/Requests/AssetCheckoutRequest.php
index d6ed2d590a,35d17537ba..a4c6f8e00d
--- a/app/Http/Requests/AssetCheckoutRequest.php
+++ b/app/Http/Requests/AssetCheckoutRequest.php
@@@ -22,12 -22,14 +22,13 @@@ class AssetCheckoutRequest extends Requ
public function rules()
{
$rules = [
- "assigned_user" => 'required_without_all:assigned_asset,assigned_location',
- "assigned_asset" => 'required_without_all:assigned_user,assigned_location',
- "assigned_location" => 'required_without_all:assigned_user,assigned_asset',
+ 'assigned_user' => 'required_without_all:assigned_asset,assigned_location',
+ 'assigned_asset' => 'required_without_all:assigned_user,assigned_location',
+ 'assigned_location' => 'required_without_all:assigned_user,assigned_asset',
+ 'status_id' => 'exists:status_labels,id,deployable,1',
- "checkout_to_type" => 'required|in:asset,location,user'
+ 'checkout_to_type' => 'required|in:asset,location,user',
];
-
return $rules;
}
}
diff --cc app/Models/Actionlog.php
index de313a1b26,41a8feb64f..8d430c79d9
--- a/app/Models/Actionlog.php
+++ b/app/Models/Actionlog.php
@@@ -17,24 -14,23 +17,24 @@@ use Illuminate\Support\Facades\Auth
*/
class Actionlog extends SnipeModel
{
- protected $presenter = "App\Presenters\ActionlogPresenter";
+ use HasFactory;
+
+ protected $presenter = \App\Presenters\ActionlogPresenter::class;
use SoftDeletes;
use Presentable;
- protected $dates = [ 'deleted_at' ];
- protected $table = 'action_logs';
+ protected $table = 'action_logs';
public $timestamps = true;
- protected $fillable = [ 'created_at', 'item_type','user_id','item_id','action_type','note','target_id', 'target_type' ];
+ protected $fillable = ['created_at', 'item_type', 'user_id', 'item_id', 'action_type', 'note', 'target_id', 'target_type', 'stored_eula', 'stored_eula_file'];
use Searchable;
-
+
/**
* The attributes that should be included when searching the model.
- *
+ *
* @var array
*/
- protected $searchableAttributes = ['action_type', 'note', 'log_meta'];
+ protected $searchableAttributes = ['action_type', 'note', 'log_meta','user_id'];
/**
* The relations and their attributes that should be included when searching the model.
@@@ -183,11 -181,11 +186,12 @@@
* @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
- public function location() {
- return $this->belongsTo('\App\Models\Location', 'location_id' )->withTrashed();
+ public function location()
+ {
+ return $this->belongsTo(\App\Models\Location::class, 'location_id')->withTrashed();
}
+
/**
* Check if the file exists, and if it does, force a download
*
diff --cc app/Models/License.php
index bcdcf3128e,fa2b3b6eac..2c7efacf23
--- a/app/Models/License.php
+++ b/app/Models/License.php
@@@ -186,10 -184,11 +186,11 @@@ class License extends Depreciabl
];
}
//Chunk and use DB transactions to prevent timeouts.
+
collect($licenseInsert)->chunk(1000)->each(function ($chunk) {
DB::transaction(function () use ($chunk) {
- LicenseSeat::insert($chunk->toArray());
- });
+ LicenseSeat::insert($chunk->toArray());
+ });
});
// On initial create, we shouldn't log the addition of seats.
diff --cc app/Models/Loggable.php
index 33e66d44e0,4d1eb1fd64..cf5eabc67b
--- a/app/Models/Loggable.php
+++ b/app/Models/Loggable.php
@@@ -114,11 -116,10 +114,14 @@@ trait Loggabl
$log->location_id = null;
$log->note = $note;
$log->action_date = $action_date;
+ if (! $log->action_date) {
+ $log->action_date = date('Y-m-d H:i:s');
+ }
+ if (! $log->action_date) {
+ $log->action_date = date('Y-m-d H:i:s');
+ }
+
if (Auth::user()) {
$log->user_id = Auth::user()->id;
}
diff --cc app/Models/User.php
index c54b144725,861a62d9eb..1cd39abbf1
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@@ -495,30 -495,40 +496,32 @@@ class User extends SnipeModel implement
if (strpos($users_name, ' ') === false) {
$first_name = $users_name;
$last_name = '';
- $username = $users_name;
-
+ $username = $users_name;
} else {
+
- list($first_name, $last_name) = explode(" ", $users_name, 2);
+ list($first_name, $last_name) = explode(' ', $users_name, 2);
// Assume filastname by default
$username = str_slug(substr($first_name, 0, 1).$last_name);
- if ($format == 'firstname.lastname') {
- $username = str_slug($first_name).'.'.str_slug($last_name);
+ if ($format=='firstname.lastname') {
+ $username = str_slug($first_name) . '.' . str_slug($last_name);
+
- } elseif ($format=='lastnamefirstinitial') {
+ } elseif ($format == 'lastnamefirstinitial') {
$username = str_slug($last_name.substr($first_name, 0, 1));
-
- } elseif ($format=='firstintial.lastname') {
+ } elseif ($format == 'firstintial.lastname') {
$username = substr($first_name, 0, 1).'.'.str_slug($last_name);
-
- } elseif ($format=='firstname_lastname') {
+ } elseif ($format == 'firstname_lastname') {
$username = str_slug($first_name).'_'.str_slug($last_name);
-
- } elseif ($format=='firstname') {
+ } elseif ($format == 'firstname') {
$username = str_slug($first_name);
- }
- elseif ($format=='firstinitial.lastname') {
- $username = str_slug(substr($first_name, 0, 1). '.' . str_slug($last_name));
- }
- elseif ($format=='lastname_firstinitial') {
+ } elseif ($format == 'firstinitial.lastname') {
+ $username = str_slug(substr($first_name, 0, 1).'.'.str_slug($last_name));
+ } elseif ($format == 'lastname_firstinitial') {
$username = str_slug($last_name).'_'.str_slug(substr($first_name, 0, 1));
- }
- elseif ($format=='firstnamelastname') {
- $username = str_slug($first_name) . str_slug($last_name);
- }
- elseif ($format=='firstnamelastinitial') {
+ } elseif ($format == 'firstnamelastname') {
+ $username = str_slug($first_name).str_slug($last_name);
+ } elseif ($format == 'firstnamelastinitial') {
$username = str_slug(($first_name.substr($last_name, 0, 1)));
}
}
@@@ -526,8 -536,9 +529,9 @@@
$user['first_name'] = $first_name;
$user['last_name'] = $last_name;
$user['username'] = strtolower($username);
- return $user;
+
+ return $user;
}
/**
@@@ -578,11 -591,12 +582,11 @@@
return true;
}
// If the 2FA is required for everyone and the user has enrolled
- elseif ((Setting::getSettings()->two_factor_enabled =='2') && ($this->two_factor_enrolled))
- {
+ elseif ((Setting::getSettings()->two_factor_enabled == '2') && ($this->two_factor_enrolled)) {
return true;
}
-
return false;
+
}
diff --cc app/Observers/AssetObserver.php
index 3c23f59c83,9dc9f2d083..78fd4c451c
--- a/app/Observers/AssetObserver.php
+++ b/app/Observers/AssetObserver.php
@@@ -18,14 -18,13 +18,14 @@@ class AssetObserve
public function updating(Asset $asset)
{
$attributes = $asset->getAttributes();
- $attributesOriginal = $asset->getAttributes();
+ $attributesOriginal = $asset->getOriginal();
-// If the asset isn't being checked out or audited, log the update.
-// (Those other actions already create log entries.)
- if (($attributes['assigned_to'] == $attributesOriginal['assigned_to'])
+
+ // If the asset isn't being checked out or audited, log the update.
+ // (Those other actions already create log entries.)
+ if (($attributes['assigned_to'] == $attributesOriginal['assigned_to'])
&& ((isset( $attributes['next_audit_date']) ? $attributes['next_audit_date'] : null) == (isset($attributesOriginal['next_audit_date']) ? $attributesOriginal['next_audit_date']: null))
- && ($attributes['last_checkout'] == $attributesOriginal['last_checkout'])) {
-
+ && ($attributes['last_checkout'] == $attributesOriginal['last_checkout']))
+ {
$changed = [];
foreach ($asset->getOriginal() as $key => $value) {
diff --cc database/factories/LicenseFactory.php
index 30bcaca755,96b77bc14b..2aa681c0d2
--- a/database/factories/LicenseFactory.php
+++ b/database/factories/LicenseFactory.php
@@@ -14,108 -13,83 +13,109 @@@ use Illuminate\Database\Eloquent\Factor
|
*/
-$factory->define(App\Models\License::class, function (Faker\Generator $faker) {
-
- return [
- 'user_id' => 1,
- 'name' => $this->faker->name,
- 'license_email' => $faker->safeEmail,
- 'serial' => $faker->uuid,
- 'notes' => 'Created by DB seeder',
- 'seats' => $this->faker->numberBetween(1, 10),
- 'purchase_date' => $faker->dateTimeBetween('-1 years','now', date_default_timezone_get()),
- 'order_number' => $faker->numberBetween(1000000, 50000000),
- 'expiration_date' => $faker->dateTimeBetween('now', '+3 years', date_default_timezone_get())->format('Y-m-d H:i:s'),
- 'reassignable' => $faker->boolean(),
- 'termination_date' => $faker->dateTimeBetween('-1 years','now', date_default_timezone_get())->format('Y-m-d H:i:s'),
- 'supplier_id' => $faker->numberBetween(1,5),
- 'category_id' => Category::where('category_type', '=', 'license')->inRandomOrder()->first()->id,
- ];
-});
-
// 1
-$factory->state(App\Models\License::class, 'photoshop', function ($faker) {
- $data = [
- 'name' => 'Photoshop',
- 'manufacturer_id' => 9,
- 'purchase_cost' => '299.99',
- 'seats' => 10,
- 'purchase_order' => '13503Q',
- 'maintained' => true,
- 'category_id' => 14,
- ];
-
- return $data;
-
-});
// 2
-$factory->state(App\Models\License::class, 'acrobat', function ($faker) {
-
- $data = [
- 'name' => 'Acrobat',
- 'manufacturer_id' => 9,
- 'purchase_cost' => '29.99',
- 'seats' => 10,
- 'category_id' => 14,
- ];
-
-
- return $data;
-});
// 3
-$factory->state(App\Models\License::class, 'indesign', function ($faker) {
- $data = [
- 'name' => 'InDesign',
- 'manufacturer_id' => 9,
- 'purchase_cost' => '199.99',
- 'seats' => 10,
- 'category_id' => 14,
- ];
-
-
- return $data;
-});
-
// 4
-$factory->state(App\Models\License::class, 'office', function ($faker) {
- $data = [
- 'name' => 'Office',
- 'manufacturer_id' => 2,
- 'purchase_cost' => '49.99',
- 'seats' => 20,
- 'category_id' => 15,
- ];
-
-
- return $data;
-});
+class LicenseFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\License::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+
+
+ return [
+ 'user_id' => 1,
+ 'name' => $this->faker->name,
+ 'license_email' => $this->faker->safeEmail,
+ 'serial' => $this->faker->uuid,
+ 'notes' => 'Created by DB seeder',
+ 'seats' => $this->faker->numberBetween(1, 10),
+ 'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
+ 'order_number' => $this->faker->numberBetween(1000000, 50000000),
+ 'expiration_date' => $this->faker->dateTimeBetween('now', '+3 years', date_default_timezone_get())->format('Y-m-d H:i:s'),
+ 'reassignable' => $this->faker->boolean(),
+ 'termination_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d H:i:s'),
+ 'supplier_id' => $this->faker->numberBetween(1, 5),
+ 'category_id' => Category::where('category_type', '=', 'license')->inRandomOrder()->first()->id
+ ];
+ }
+
+ public function photoshop()
+ {
+ return $this->state(function () {
+ $data = [
+ 'name' => 'Photoshop',
+ 'manufacturer_id' => 9,
+ 'purchase_cost' => '299.99',
+ 'seats' => 10,
+ 'purchase_order' => '13503Q',
+ 'maintained' => true,
+ 'category_id' => 14,
+ ];
+
+ return $data;
+ });
+ }
+
+ public function acrobat()
+ {
+ return $this->state(function () {
+ $data = [
+ 'name' => 'Acrobat',
+ 'manufacturer_id' => 9,
+ 'purchase_cost' => '29.99',
+ 'seats' => 10,
+ 'category_id' => 14,
+ ];
+
+ return $data;
+ });
+ }
+
+ public function indesign()
+ {
+ return $this->state(function () {
+ $data = [
+ 'name' => 'InDesign',
+ 'manufacturer_id' => 9,
+ 'purchase_cost' => '199.99',
+ 'seats' => 10,
+ 'category_id' => 14,
+ ];
++
+ return $data;
+ });
+ }
+
+ public function office()
+ {
+ return $this->state(function () {
+ $data = [
+ 'name' => 'Office',
+ 'manufacturer_id' => 2,
+ 'purchase_cost' => '49.99',
+ 'seats' => 20,
+ 'category_id' => 15,
+ ];
+
+ return $data;
+ });
+ }
+}
diff --cc database/migrations/2015_09_21_235926_create_custom_field_custom_fieldset.php
index 6e56769d5c,ccf25c75b9..ff22d14b16
--- a/database/migrations/2015_09_21_235926_create_custom_field_custom_fieldset.php
+++ b/database/migrations/2015_09_21_235926_create_custom_field_custom_fieldset.php
@@@ -1,34 -1,37 +1,36 @@@
<?php
- use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+ use Illuminate\Database\Migrations\Migration;
-class CreateCustomFieldCustomFieldset extends Migration {
-
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('custom_field_custom_fieldset', function(Blueprint $table)
+class CreateCustomFieldCustomFieldset extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::create('custom_field_custom_fieldset', function (Blueprint $table) {
+ {
+ $table->bigIncrements('id');
- $table->integer('custom_field_id');
- $table->integer('custom_fieldset_id');
- $table->integer('order');
- $table->boolean('required');
+ $table->integer('custom_field_id');
+ $table->integer('custom_fieldset_id');
-
+ $table->integer('order');
+ $table->boolean('required');
$table->engine = 'InnoDB';
- });
-
- }
+ });
+
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::drop('custom_field_custom_fieldset');
- }
+ }
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::drop('custom_field_custom_fieldset');
+ }
}