73acf6e5e8
commitd55c176199Merge:93ff9524dc0451fe17Author: snipe <snipe@snipe.net> Date: Wed Mar 16 18:35:42 2022 +0000 Merge pull request #10831 from snipe/merges/master_down_to_develop_march_16 v6.0.0-RC-5 - Merges master down to develop commitc0451fe17aAuthor: snipe <snipe@snipe.net> Date: Wed Mar 16 18:10:17 2022 +0000 Bumped version to v6.0.0-RC-5 Signed-off-by: snipe <snipe@snipe.net> commit0f95802699Author: snipe <snipe@snipe.net> Date: Wed Mar 16 18:05:47 2022 +0000 Fixed mis-automerge Signed-off-by: snipe <snipe@snipe.net> commit9db8bd782dAuthor: snipe <snipe@snipe.net> Date: Wed Mar 16 18:02:07 2022 +0000 Merging master down into develop Signed-off-by: snipe <snipe@snipe.net> commit93ff9524d6Merge:40a94707789ddbddadAuthor: snipe <snipe@snipe.net> Date: Wed Mar 16 10:04:58 2022 -0700 Merge pull request #10829 from snipe/features/add_statuslabel_filter_by_type_in_api Added filter by status_type in StatusLabels API index endpoint commit89ddbddadaAuthor: snipe <snipe@snipe.net> Date: Wed Mar 16 16:53:18 2022 +0000 Fixed comment Signed-off-by: snipe <snipe@snipe.net> commit7498fe36e9Author: snipe <snipe@snipe.net> Date: Wed Mar 16 16:45:03 2022 +0000 Removed extra space because pedantry Signed-off-by: snipe <snipe@snipe.net> commitbabf7c064bAuthor: snipe <snipe@snipe.net> Date: Wed Mar 16 16:38:45 2022 +0000 Added ability to filter status label index endpoint by status type Signed-off-by: snipe <snipe@snipe.net> commit40a9470770Merge:f499dcf7c781b42601Author: snipe <snipe@snipe.net> Date: Wed Mar 16 08:54:10 2022 -0700 Merge pull request #10828 from snipe/fixes/10826_parse_error_on_print_all Fixed #10826 - parse error on translation string for print all assets commit781b426018Author: snipe <snipe@snipe.net> Date: Wed Mar 16 08:50:47 2022 -0700 Fixed #10826 - parse error on translation string for print all assets Signed-off-by: snipe <snipe@snipe.net> commitf499dcf7c3Merge:84aa26dd554d6a4d97Author: snipe <snipe@snipe.net> Date: Wed Mar 16 08:25:29 2022 -0700 Merge pull request #10827 from snipe/fixes/modal_dropdowns_broken Fixed #10825 - selectlists in modals b0rked commit54d6a4d978Author: snipe <snipe@snipe.net> Date: Wed Mar 16 08:23:50 2022 -0700 Fixed #10825 - selectlists in modals b0rked Signed-off-by: snipe <snipe@snipe.net> commit84aa26dd50Merge:8984b3a5914bd07e97Author: snipe <snipe@snipe.net> Date: Thu Mar 10 13:02:45 2022 -0800 Merge pull request #10728 from Godmartinz/gh10191-css-dropdownmenu Fixed #10191 - font color contrast on mobile menu commit8984b3a59dMerge:d06ef4bdecdc0805fcAuthor: snipe <snipe@snipe.net> Date: Thu Mar 10 10:40:33 2022 -0800 Merge pull request #10812 from inietov/fixes/CarbonExceptions_InvalidFormatException_DateTime_develop Fixes Carbon\Exceptions\InvalidFormatException: DateTime::__construct(): Failed to parse time string develop commitcdc0805fc4Author: Ivan Nieto Vivanco <inietov@gmail.com> Date: Thu Mar 10 12:07:07 2022 -0600 Sanitize dates input in the importer before saving commit14bd07e97dMerge:4435ea95f16fd10954Author: Godfrey M <godmartinz@gmail.com> Date: Thu Mar 3 10:14:30 2022 -0800 gerge branchevelop' into gh10191-css-dropdownmenu commit4435ea95fdAuthor: Godfrey M <godmartinz@gmail.com> Date: Thu Mar 3 09:47:11 2022 -0800 removes changes to mix-manifest commitf115385243Author: Godfrey M <godmartinz@gmail.com> Date: Thu Mar 3 09:32:05 2022 -0800 C&P mix-manifest to be tracked commit708dc08b4fAuthor: Godfrey M <godmartinz@gmail.com> Date: Wed Feb 23 11:17:44 2022 -0800 mixes color contrast on dropdown menu from navbar on file Signed-off-by: snipe <snipe@snipe.net>
165 lines
4.3 KiB
PHP
Executable File
165 lines
4.3 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Http\Traits\UniqueUndeletedTrait;
|
|
use App\Models\Traits\Searchable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Watson\Validating\ValidatingTrait;
|
|
|
|
class Statuslabel extends SnipeModel
|
|
{
|
|
use HasFactory;
|
|
use SoftDeletes;
|
|
use ValidatingTrait;
|
|
use UniqueUndeletedTrait;
|
|
|
|
protected $injectUniqueIdentifier = true;
|
|
|
|
protected $table = 'status_labels';
|
|
protected $hidden = ['user_id', 'deleted_at'];
|
|
|
|
protected $rules = [
|
|
'name' => 'required|string|unique_undeleted',
|
|
'notes' => 'string|nullable',
|
|
'deployable' => 'required',
|
|
'pending' => 'required',
|
|
'archived' => 'required',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'archived',
|
|
'deployable',
|
|
'name',
|
|
'notes',
|
|
'pending',
|
|
];
|
|
|
|
use Searchable;
|
|
|
|
/**
|
|
* The attributes that should be included when searching the model.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $searchableAttributes = ['name', 'notes'];
|
|
|
|
/**
|
|
* The relations and their attributes that should be included when searching the model.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $searchableRelations = [];
|
|
|
|
/**
|
|
* Establishes the status label -> assets relationship
|
|
*
|
|
* @author A. Gianotto <snipe@snipe.net>
|
|
* @since [v1.0]
|
|
* @return \Illuminate\Database\Eloquent\Relations\Relation
|
|
*/
|
|
public function assets()
|
|
{
|
|
return $this->hasMany(\App\Models\Asset::class, 'status_id');
|
|
}
|
|
|
|
/**
|
|
* Gets the status label type
|
|
*
|
|
* @author A. Gianotto <snipe@snipe.net>
|
|
* @since [v1.0]
|
|
* @return string
|
|
*/
|
|
public function getStatuslabelType()
|
|
{
|
|
if (($this->pending == '1') && ($this->archived == '0') && ($this->deployable == '0')) {
|
|
return 'pending';
|
|
} elseif (($this->pending == '0') && ($this->archived == '1') && ($this->deployable == '0')) {
|
|
return 'archived';
|
|
} elseif (($this->pending == '0') && ($this->archived == '0') && ($this->deployable == '0')) {
|
|
return 'undeployable';
|
|
}
|
|
|
|
return 'deployable';
|
|
}
|
|
|
|
/**
|
|
* Query builder scope to for pending status types
|
|
*
|
|
* @return \Illuminate\Database\Query\Builder Modified query builder
|
|
*/
|
|
public function scopePending()
|
|
{
|
|
return $this->where('pending', '=', 1)
|
|
->where('archived', '=', 0)
|
|
->where('deployable', '=', 0);
|
|
}
|
|
|
|
/**
|
|
* Query builder scope for archived status types
|
|
*
|
|
* @return \Illuminate\Database\Query\Builder Modified query builder
|
|
*/
|
|
public function scopeArchived()
|
|
{
|
|
return $this->where('pending', '=', 0)
|
|
->where('archived', '=', 1)
|
|
->where('deployable', '=', 0);
|
|
}
|
|
|
|
/**
|
|
* Query builder scope for deployable status types
|
|
*
|
|
* @return \Illuminate\Database\Query\Builder Modified query builder
|
|
*/
|
|
public function scopeDeployable()
|
|
{
|
|
return $this->where('pending', '=', 0)
|
|
->where('archived', '=', 0)
|
|
->where('deployable', '=', 1);
|
|
}
|
|
|
|
/**
|
|
* Query builder scope for undeployable status types
|
|
*
|
|
* @return \Illuminate\Database\Query\Builder Modified query builder
|
|
*/
|
|
public function scopeUndeployable()
|
|
{
|
|
return $this->where('pending', '=', 0)
|
|
->where('archived', '=', 0)
|
|
->where('deployable', '=', 0);
|
|
}
|
|
|
|
/**
|
|
* Helper function to determine type attributes
|
|
*
|
|
* @author A. Gianotto <snipe@snipe.net>
|
|
* @since [v1.0]
|
|
* @return string
|
|
*/
|
|
public static function getStatuslabelTypesForDB($type)
|
|
{
|
|
$statustype['pending'] = 0;
|
|
$statustype['deployable'] = 0;
|
|
$statustype['archived'] = 0;
|
|
|
|
if ($type == 'pending') {
|
|
$statustype['pending'] = 1;
|
|
$statustype['deployable'] = 0;
|
|
$statustype['archived'] = 0;
|
|
} elseif ($type == 'deployable') {
|
|
$statustype['pending'] = 0;
|
|
$statustype['deployable'] = 1;
|
|
$statustype['archived'] = 0;
|
|
} elseif ($type == 'archived') {
|
|
$statustype['pending'] = 0;
|
|
$statustype['deployable'] = 0;
|
|
$statustype['archived'] = 1;
|
|
}
|
|
|
|
return $statustype;
|
|
}
|
|
}
|