Skip to content

A free open source IT asset/license management system

Code formatting fixes

snipe95f867b26759
diff --git a/app/Models/Accessory.php b/app/Models/Accessory.php
index cd0bfaca60..18c0b853c6 100755
--- a/app/Models/Accessory.php
+++ b/app/Models/Accessory.php
@@ -15,7 +15,7 @@ use Watson\Validating\ValidatingTrait;
/**
* Model for Accessories.
*
- * @version v1.0
+ * @version v1.0
*/
class Accessory extends SnipeModel
{
@@ -56,8 +56,8 @@ class Accessory extends SnipeModel
];
/**
- * Accessory validation rules
- */
+ * Accessory validation rules
+ */
public $rules = [
'name' => 'required|min:3|max:255',
'qty' => 'required|integer|min:1',
@@ -71,12 +71,12 @@ class Accessory extends SnipeModel
/**
- * Whether the model should inject it's identifier to the unique
- * validation rules before attempting validation. If this property
- * is not set in the model it will default to true.
- *
+ * Whether the model should inject it's identifier to the unique
+ * validation rules before attempting validation. If this property
+ * is not set in the model it will default to true.
+ *
* @var bool
- */
+ */
protected $injectUniqueIdentifier = true;
use ValidatingTrait;
@@ -108,7 +108,7 @@ class Accessory extends SnipeModel
* Establishes the accessory -> supplier relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function supplier()
@@ -121,7 +121,7 @@ class Accessory extends SnipeModel
* Sets the requestable attribute on the accessory
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return void
*/
public function setRequestableAttribute($value)
@@ -136,7 +136,7 @@ class Accessory extends SnipeModel
* Establishes the accessory -> company relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function company()
@@ -148,7 +148,7 @@ class Accessory extends SnipeModel
* Establishes the accessory -> location relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function location()
@@ -160,7 +160,7 @@ class Accessory extends SnipeModel
* Establishes the accessory -> category relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function category()
@@ -172,7 +172,7 @@ class Accessory extends SnipeModel
* Returns the action logs associated with the accessory
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assetlog()
@@ -201,8 +201,8 @@ class Accessory extends SnipeModel
*
* It's super-mega-assy, but it's the best I could do for now.
*
- * @author A. Gianotto <[email protected]>
- * @since v5.0.0
+ * @author A. Gianotto <[email protected]>
+ * @since v5.0.0
*
* @see \App\Http\Controllers\Api\AccessoriesController\checkedout()
*/
@@ -219,7 +219,7 @@ class Accessory extends SnipeModel
* presenter or service provider
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return string
*/
public function getImageUrl()
@@ -235,7 +235,7 @@ class Accessory extends SnipeModel
* Establishes the accessory -> users relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function checkouts()
@@ -248,7 +248,7 @@ class Accessory extends SnipeModel
* Establishes the accessory -> admin user relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v7.0.13]
+ * @since [v7.0.13]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function adminuser()
@@ -260,7 +260,7 @@ class Accessory extends SnipeModel
* Checks whether or not the accessory has users
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return int
*/
public function hasUsers()
@@ -274,7 +274,7 @@ class Accessory extends SnipeModel
* Establishes the accessory -> manufacturer relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function manufacturer()
@@ -287,7 +287,7 @@ class Accessory extends SnipeModel
* accessory based on the category it belongs to.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return bool
*/
public function checkin_email()
@@ -300,7 +300,7 @@ class Accessory extends SnipeModel
* accept it via email.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return bool
*/
public function requireAcceptance()
@@ -313,7 +313,7 @@ class Accessory extends SnipeModel
* checks for a settings level EULA
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return string
*/
public function getEula()
@@ -333,7 +333,7 @@ class Accessory extends SnipeModel
* Check how many items within an accessory are checked out
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v5.0]
+ * @since [v5.0]
* @return int
*/
public function numCheckedOut()
@@ -350,7 +350,7 @@ class Accessory extends SnipeModel
* bad things happen.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return int
*/
public function numRemaining()
@@ -365,8 +365,8 @@ class Accessory extends SnipeModel
/**
* Run after the checkout acceptance was declined by the user
*
- * @param User $acceptedBy
- * @param string $signature
+ * @param User $acceptedBy
+ * @param string $signature
*/
public function declinedCheckout(User $declinedBy, $signature)
{
@@ -392,8 +392,8 @@ class Accessory extends SnipeModel
* This simply checks that there is a value for quantity, and if there isn't, set it to 0.
*
* @author A. Gianotto <[email protected]>
- * @since v6.3.4
- * @param $value
+ * @since v6.3.4
+ * @param $value
* @return void
*/
public function setQtyAttribute($value)
@@ -410,7 +410,6 @@ class Accessory extends SnipeModel
/**
* Query builder scope to order on created_by name
- *
*/
public function scopeOrderByCreatedByName($query, $order)
{
@@ -418,68 +417,68 @@ class Accessory extends SnipeModel
}
/**
- * Query builder scope to order on company
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ * Query builder scope to order on company
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeOrderCompany($query, $order)
{
return $query->leftJoin('companies', 'accessories.company_id', '=', 'companies.id')
- ->orderBy('companies.name', $order);
+ ->orderBy('companies.name', $order);
}
/**
- * Query builder scope to order on category
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ * Query builder scope to order on category
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeOrderCategory($query, $order)
{
return $query->leftJoin('categories', 'accessories.category_id', '=', 'categories.id')
- ->orderBy('categories.name', $order);
+ ->orderBy('categories.name', $order);
}
/**
- * Query builder scope to order on location
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ * Query builder scope to order on location
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeOrderLocation($query, $order)
{
return $query->leftJoin('locations', 'accessories.location_id', '=', 'locations.id')
- ->orderBy('locations.name', $order);
+ ->orderBy('locations.name', $order);
}
/**
- * Query builder scope to order on manufacturer
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ * Query builder scope to order on manufacturer
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeOrderManufacturer($query, $order)
{
return $query->leftJoin('manufacturers', 'accessories.manufacturer_id', '=', 'manufacturers.id')->orderBy('manufacturers.name', $order);
}
/**
- * Query builder scope to order on supplier
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ * Query builder scope to order on supplier
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeOrderSupplier($query, $order)
{
return $query->leftJoin('suppliers', 'accessories.supplier_id', '=', 'suppliers.id')->orderBy('suppliers.name', $order);
diff --git a/app/Models/AccessoryCheckout.php b/app/Models/AccessoryCheckout.php
index 61ffcd08e5..9f49354389 100755
--- a/app/Models/AccessoryCheckout.php
+++ b/app/Models/AccessoryCheckout.php
@@ -16,7 +16,7 @@ use Watson\Validating\ValidatingTrait;
/**
* Model for Accessories.
*
- * @version v1.0
+ * @version v1.0
*/
class AccessoryCheckout extends Model
{
@@ -36,7 +36,7 @@ class AccessoryCheckout extends Model
* Establishes the accessory checkout -> accessory relationship
*
* @author [A. Kroeger]
- * @since [v7.0.9]
+ * @since [v7.0.9]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function accessory()
@@ -52,7 +52,7 @@ class AccessoryCheckout extends Model
* Establishes the accessory checkout -> user relationship
*
* @author [A. Kroeger]
- * @since [v7.0.9]
+ * @since [v7.0.9]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function adminuser()
@@ -64,7 +64,7 @@ class AccessoryCheckout extends Model
* Get the target this asset is checked out to
*
* @author [A. Kroeger]
- * @since [v7.0]
+ * @since [v7.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assignedTo()
@@ -76,7 +76,7 @@ class AccessoryCheckout extends Model
* Gets the lowercased name of the type of target the asset is assigned to
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return string
*/
public function assignedType()
@@ -91,7 +91,7 @@ class AccessoryCheckout extends Model
* this method is an easy way of seeing if we are checked out to a user.
*
* @author [A. Kroeger]
- * @since [v7.0]
+ * @since [v7.0]
*/
public function checkedOutToUser(): bool
{
@@ -127,50 +127,64 @@ class AccessoryCheckout extends Model
* Run additional, advanced searches.
*
* @param \Illuminate\Database\Eloquent\Builder $query
- * @param array $terms The search terms
+ * @param array $terms The search terms
* @return \Illuminate\Database\Eloquent\Builder
*/
public function advancedTextSearch(Builder $query, array $terms)
{
- $userQuery = User::where(function ($query) use ($terms) {
- foreach ($terms as $term) {
- $search_str = '%' . $term . '%';
- $query->where('first_name', 'like', $search_str)
- ->orWhere('last_name', 'like', $search_str)
- ->orWhere('note', 'like', $search_str);
+ $userQuery = User::where(
+ function ($query) use ($terms) {
+ foreach ($terms as $term) {
+ $search_str = '%' . $term . '%';
+ $query->where('first_name', 'like', $search_str)
+ ->orWhere('last_name', 'like', $search_str)
+ ->orWhere('note', 'like', $search_str);
+ }
}
- })->select('id');
-
- $locationQuery = Location::where(function ($query) use ($terms) {
- foreach ($terms as $term) {
- $search_str = '%' . $term . '%';
- $query->where('name', 'like', $search_str);
+ )->select('id');
+
+ $locationQuery = Location::where(
+ function ($query) use ($terms) {
+ foreach ($terms as $term) {
+ $search_str = '%' . $term . '%';
+ $query->where('name', 'like', $search_str);
+ }
+ }
+ )->select('id');
+
+ $assetQuery = Asset::where(
+ function ($query) use ($terms) {
+ foreach ($terms as $term) {
+ $search_str = '%' . $term . '%';
+ $query->where('name', 'like', $search_str);
+ }
}
- })->select('id');
+ )->select('id');
- $assetQuery = Asset::where(function ($query) use ($terms) {
- foreach ($terms as $term) {
- $search_str = '%' . $term . '%';
- $query->where('name', 'like', $search_str);
+ $query->where(
+ function ($query) use ($userQuery) {
+ $query->where('assigned_type', User::class)
+ ->whereIn('assigned_to', $userQuery);
+ }
+ )->orWhere(
+ function ($query) use ($locationQuery) {
+ $query->where('assigned_type', Location::class)
+ ->whereIn('assigned_to', $locationQuery);
+ }
+ )->orWhere(
+ function ($query) use ($assetQuery) {
+ $query->where('assigned_type', Asset::class)
+ ->whereIn('assigned_to', $assetQuery);
}
- })->select('id');
-
- $query->where(function ($query) use ($userQuery) {
- $query->where('assigned_type', User::class)
- ->whereIn('assigned_to', $userQuery);
- })->orWhere(function($query) use ($locationQuery) {
- $query->where('assigned_type', Location::class)
- ->whereIn('assigned_to', $locationQuery);
- })->orWhere(function($query) use ($assetQuery) {
- $query->where('assigned_type', Asset::class)
- ->whereIn('assigned_to', $assetQuery);
- })->orWhere(function($query) use ($terms) {
- foreach ($terms as $term) {
- $search_str = '%' . $term . '%';
- $query->where('note', 'like', $search_str);
+ )->orWhere(
+ function ($query) use ($terms) {
+ foreach ($terms as $term) {
+ $search_str = '%' . $term . '%';
+ $query->where('note', 'like', $search_str);
+ }
}
- });
+ );
return $query;
}
diff --git a/app/Models/Actionlog.php b/app/Models/Actionlog.php
index 2a86dd0e18..e083a8bfe5 100755
--- a/app/Models/Actionlog.php
+++ b/app/Models/Actionlog.php
@@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* Model for the Actionlog (the table that keeps a historical log of
* checkouts, checkins, and updates).
*
- * @version v1.0
+ * @version v1.0
*/
class Actionlog extends SnipeModel
{
@@ -96,29 +96,31 @@ class Actionlog extends SnipeModel
* Override from Builder to automatically add the company
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public static function boot()
{
parent::boot();
- static::creating(function (self $actionlog) {
- // If the admin is a superadmin, let's see if the target instead has a company.
- if (auth()->user() && auth()->user()->isSuperUser()) {
- if ($actionlog->target) {
- $actionlog->company_id = $actionlog->target->company_id;
- } elseif ($actionlog->item) {
- $actionlog->company_id = $actionlog->item->company_id;
+ static::creating(
+ function (self $actionlog) {
+ // If the admin is a superadmin, let's see if the target instead has a company.
+ if (auth()->user() && auth()->user()->isSuperUser()) {
+ if ($actionlog->target) {
+ $actionlog->company_id = $actionlog->target->company_id;
+ } elseif ($actionlog->item) {
+ $actionlog->company_id = $actionlog->item->company_id;
+ }
+ } elseif (auth()->user() && auth()->user()->company) {
+ $actionlog->company_id = auth()->user()->company_id;
}
- } elseif (auth()->user() && auth()->user()->company) {
- $actionlog->company_id = auth()->user()->company_id;
- }
- if ($actionlog->action_date == '') {
- $actionlog->action_date = Carbon::now();
- }
+ if ($actionlog->action_date == '') {
+ $actionlog->action_date = Carbon::now();
+ }
- });
+ }
+ );
}
@@ -126,7 +128,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> item relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function item()
@@ -138,7 +140,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> company relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function company()
@@ -151,7 +153,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> asset relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assets()
@@ -163,7 +165,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> license relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function licenses()
@@ -175,7 +177,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> consumable relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function consumables()
@@ -187,7 +189,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> consumable relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function accessories()
@@ -199,7 +201,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> components relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function components()
@@ -211,7 +213,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> item type relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function itemType()
@@ -227,7 +229,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> target type relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function targetType()
@@ -244,7 +246,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> uploads relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function uploads()
@@ -258,7 +260,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> userlog relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function userlog()
@@ -270,7 +272,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> admin user relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function adminuser()
@@ -283,7 +285,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> user relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function user()
@@ -296,7 +298,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> target relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function target()
@@ -308,7 +310,7 @@ class Actionlog extends SnipeModel
* Establishes the actionlog -> location relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function location()
@@ -321,7 +323,7 @@ class Actionlog extends SnipeModel
* Check if the file exists, and if it does, force a download
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return string | false
*/
public function get_src($type = 'assets', $fieldname = 'filename')
@@ -339,7 +341,7 @@ class Actionlog extends SnipeModel
* Saves the log record with the action type
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return bool
*/
public function logaction($actiontype)
@@ -360,7 +362,7 @@ class Actionlog extends SnipeModel
* Calculate the number of days until the next audit
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return int
*/
public function daysUntilNextAudit($monthInterval = 12, $asset = null)
@@ -389,7 +391,7 @@ class Actionlog extends SnipeModel
* Calculate the date of the next audit
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return \Datetime
*/
public function calcNextAuditDate($monthInterval = 12, $asset = null)
@@ -406,8 +408,8 @@ class Actionlog extends SnipeModel
/**
* Gets action logs in chronological order, excluding uploads
*
- * @author Vincent Sposato <[email protected]>
- * @since v1.0
+ * @author Vincent Sposato <[email protected]>
+ * @since v1.0
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getListingOfActionLogsChronologicalOrder()
@@ -423,7 +425,7 @@ class Actionlog extends SnipeModel
* Determines what the type of request is so we can log it to the action_log
*
* @author A. Gianotto <[email protected]>
- * @since v6.3.0
+ * @since v6.3.0
* @return string
*/
public function determineActionSource(): string
@@ -435,7 +437,8 @@ class Actionlog extends SnipeModel
// This is an API call
if (((request()->header('content-type') && (request()->header('accept'))=='application/json'))
- && (starts_with(request()->header('authorization'), 'Bearer '))) {
+ && (starts_with(request()->header('authorization'), 'Bearer '))
+ ) {
return 'api';
}
@@ -453,24 +456,24 @@ class Actionlog extends SnipeModel
{
switch ($this->item_type) {
- case Accessory::class:
- return route('show.accessoryfile', [$this->item_id, $this->id]);
- case Asset::class:
- return route('show/assetfile', [$this->item_id, $this->id]);
- case AssetModel::class:
- return route('show/modelfile', [$this->item_id, $this->id]);
- case Consumable::class:
- return route('show/locationsfile', [$this->item_id, $this->id]);
- case Component::class:
- return route('show.componentfile', [$this->item_id, $this->id]);
- case License::class:
- return route('show.licensefile', [$this->item_id, $this->id]);
- case Location::class:
- return route('show/locationsfile', [$this->item_id, $this->id]);
- case User::class:
- return route('show/userfile', [$this->item_id, $this->id]);
- default:
- return null;
+ case Accessory::class:
+ return route('show.accessoryfile', [$this->item_id, $this->id]);
+ case Asset::class:
+ return route('show/assetfile', [$this->item_id, $this->id]);
+ case AssetModel::class:
+ return route('show/modelfile', [$this->item_id, $this->id]);
+ case Consumable::class:
+ return route('show/locationsfile', [$this->item_id, $this->id]);
+ case Component::class:
+ return route('show.componentfile', [$this->item_id, $this->id]);
+ case License::class:
+ return route('show.licensefile', [$this->item_id, $this->id]);
+ case Location::class:
+ return route('show/locationsfile', [$this->item_id, $this->id]);
+ case User::class:
+ return route('show/userfile', [$this->item_id, $this->id]);
+ default:
+ return null;
}
}
@@ -478,24 +481,24 @@ class Actionlog extends SnipeModel
{
switch ($this->item_type) {
- case Accessory::class:
- return 'private_uploads/accessories/'.$this->filename;
- case Asset::class:
- return 'private_uploads/assets/'.$this->filename;
- case AssetModel::class:
- return 'private_uploads/assetmodels/'.$this->filename;
- case Consumable::class:
- return 'private_uploads/consumables/'.$this->filename;
- case Component::class:
- return 'private_uploads/components/'.$this->filename;
- case License::class:
- return 'private_uploads/licenses/'.$this->filename;
- case Location::class:
- return 'private_uploads/locations/'.$this->filename;
- case User::class:
- return 'private_uploads/users/'.$this->filename;
- default:
- return null;
+ case Accessory::class:
+ return 'private_uploads/accessories/'.$this->filename;
+ case Asset::class:
+ return 'private_uploads/assets/'.$this->filename;
+ case AssetModel::class:
+ return 'private_uploads/assetmodels/'.$this->filename;
+ case Consumable::class:
+ return 'private_uploads/consumables/'.$this->filename;
+ case Component::class:
+ return 'private_uploads/components/'.$this->filename;
+ case License::class:
+ return 'private_uploads/licenses/'.$this->filename;
+ case Location::class:
+ return 'private_uploads/locations/'.$this->filename;
+ case User::class:
+ return 'private_uploads/users/'.$this->filename;
+ default:
+ return null;
}
}
diff --git a/app/Models/Asset.php b/app/Models/Asset.php
index ec9a2590a3..0f6becd835 100644
--- a/app/Models/Asset.php
+++ b/app/Models/Asset.php
@@ -22,7 +22,7 @@ use Illuminate\Database\Eloquent\Casts\Attribute;
/**
* Model for Assets.
*
- * @version v1.0
+ * @version v1.0
*/
class Asset extends Depreciable
{
@@ -43,22 +43,22 @@ class Asset extends Depreciable
/**
* Run after the checkout acceptance was declined by the user
*
- * @param User $acceptedBy
- * @param string $signature
+ * @param User $acceptedBy
+ * @param string $signature
*/
public function declinedCheckout(User $declinedBy, $signature)
{
- $this->assigned_to = null;
- $this->assigned_type = null;
- $this->accepted = null;
- $this->save();
+ $this->assigned_to = null;
+ $this->assigned_type = null;
+ $this->accepted = null;
+ $this->save();
}
/**
- * The database table used by the model.
- *
- * @var string
- */
+ * The database table used by the model.
+ *
+ * @var string
+ */
protected $table = 'assets';
/**
@@ -68,12 +68,12 @@ class Asset extends Depreciable
// protected $with = ['model'];
/**
- * Whether the model should inject it's identifier to the unique
- * validation rules before attempting validation. If this property
- * is not set in the model it will default to true.
- *
+ * Whether the model should inject it's identifier to the unique
+ * validation rules before attempting validation. If this property
+ * is not set in the model it will default to true.
+ *
* @var bool
- */
+ */
protected $injectUniqueIdentifier = true;
protected $casts = [
@@ -128,10 +128,10 @@ class Asset extends Depreciable
/**
- * The attributes that are mass assignable.
- *
- * @var array
- */
+ * The attributes that are mass assignable.
+ *
+ * @var array
+ */
protected $fillable = [
'asset_tag',
'assigned_to',
@@ -220,18 +220,18 @@ class Asset extends Depreciable
$customFieldValidationRules = [];
- if (($this->model) && ($this->model->fieldset)) {
+ if (($this->model) && ($this->model->fieldset)) {
- foreach ($this->model->fieldset->fields as $field) {
+ foreach ($this->model->fieldset->fields as $field) {
- if ($field->format == 'BOOLEAN'){
- $this->{$field->db_column} = filter_var($this->{$field->db_column}, FILTER_VALIDATE_BOOLEAN);
- }
+ if ($field->format == 'BOOLEAN') {
+ $this->{$field->db_column} = filter_var($this->{$field->db_column}, FILTER_VALIDATE_BOOLEAN);
}
-
- $customFieldValidationRules += $this->model->fieldset->validation_rules();
}
+ $customFieldValidationRules += $this->model->fieldset->validation_rules();
+ }
+
return $customFieldValidationRules;
}
@@ -257,6 +257,7 @@ class Asset extends Depreciable
/**
* Returns the warranty expiration date as Carbon object
+ *
* @return \Carbon\Carbon|null
*/
public function getWarrantyExpiresAttribute()
@@ -280,7 +281,7 @@ class Asset extends Depreciable
* Establishes the asset -> company relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function company()
@@ -295,7 +296,7 @@ class Asset extends Depreciable
* that the status is deployable
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return bool
*/
public function availableForCheckout()
@@ -306,8 +307,8 @@ class Asset extends Depreciable
// The asset status is not archived and is deployable
if (($this->assetstatus) && ($this->assetstatus->archived == '0')
- && ($this->assetstatus->deployable == '1'))
- {
+ && ($this->assetstatus->deployable == '1')
+ ) {
return true;
}
@@ -322,14 +323,14 @@ class Asset extends Depreciable
* @todo The admin parameter is never used. Can probably be removed.
*
* @author [A. Gianotto] [<[email protected]>]
- * @param User $user
- * @param User $admin
- * @param Carbon $checkout_at
- * @param Carbon $expected_checkin
- * @param string $note
- * @param null $name
+ * @param User $user
+ * @param User $admin
+ * @param Carbon $checkout_at
+ * @param Carbon $expected_checkin
+ * @param string $note
+ * @param null $name
* @return bool
- * @since [v3.0]
+ * @since [v3.0]
* @return bool
*/
public function checkOut($target, $admin = null, $checkout_at = null, $expected_checkin = null, $note = null, $name = null, $location = null)
@@ -390,7 +391,7 @@ class Asset extends Depreciable
* Sets the detailedNameAttribute
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return string
*/
public function getDetailedNameAttribute()
@@ -408,7 +409,7 @@ class Asset extends Depreciable
* Pulls in the validation rules
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return array
*/
public function validationRules()
@@ -416,11 +417,12 @@ class Asset extends Depreciable
return $this->rules;
}
- public function customFieldsForCheckinCheckout($checkin_checkout) {
+ public function customFieldsForCheckinCheckout($checkin_checkout)
+ {
// Check to see if any of the custom fields were included on the form and if they have any values
if (($this->model) && ($this->model->fieldset) && ($this->model->fieldset->fields)) {
foreach ($this->model->fieldset->fields as $field) {
- if (($field->{$checkin_checkout} == 1) && (request()->has($field->db_column))){
+ if (($field->{$checkin_checkout} == 1) && (request()->has($field->db_column))) {
$this->{$field->db_column} = request()->get($field->db_column);
}
}
@@ -432,12 +434,12 @@ class Asset extends Depreciable
* Establishes the asset -> depreciation relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function depreciation()
{
- return $this->hasOneThrough(\App\Models\Depreciation::class,\App\Models\AssetModel::class,'id','id','model_id','depreciation_id');
+ return $this->hasOneThrough(\App\Models\Depreciation::class, \App\Models\AssetModel::class, 'id', 'id', 'model_id', 'depreciation_id');
}
@@ -445,7 +447,7 @@ class Asset extends Depreciable
* Get components assigned to this asset
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function components()
@@ -460,7 +462,7 @@ class Asset extends Depreciable
* @todo Is this still needed?
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function get_depreciation()
@@ -478,28 +480,28 @@ class Asset extends Depreciable
* this method is an easy way of seeing if we are checked out to a user.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
*/
public function checkedOutToUser(): bool
{
- return $this->assignedType() === self::USER;
+ return $this->assignedType() === self::USER;
}
public function checkedOutToLocation(): bool
{
- return $this->assignedType() === self::LOCATION;
+ return $this->assignedType() === self::LOCATION;
}
public function checkedOutToAsset(): bool
{
- return $this->assignedType() === self::ASSET;
+ return $this->assignedType() === self::ASSET;
}
/**
* Get the target this asset is checked out to
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assignedTo()
@@ -513,7 +515,7 @@ class Asset extends Depreciable
* Sigh.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assignedAssets()
@@ -525,7 +527,7 @@ class Asset extends Depreciable
* Establishes the accessory -> asset assignment relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assignedAccessories()
@@ -540,7 +542,7 @@ class Asset extends Depreciable
* @todo Refactor this if possible. It's awful.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return \ArrayObject
*/
public function assetLoc($iterations = 1, $first_asset = null)
@@ -581,7 +583,7 @@ class Asset extends Depreciable
* Gets the lowercased name of the type of target the asset is assigned to
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return string
*/
public function assignedType()
@@ -593,10 +595,11 @@ class Asset extends Depreciable
/**
* This is annoying, but because we don't say "assets" in our route names, we have to make an exception here
+ *
* @todo - normalize the route names - API endpoint URLS can stay the same
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v6.1.0]
+ * @since [v6.1.0]
* @return string
*/
public function targetShowRoute()
@@ -615,7 +618,7 @@ class Asset extends Depreciable
* Get the asset's location based on default RTD location
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function defaultLoc()
@@ -630,7 +633,7 @@ class Asset extends Depreciable
* and if not, check for an image uploaded to the asset model.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return string | false
*/
public function getImageUrl()
@@ -651,22 +654,22 @@ class Asset extends Depreciable
* Get the asset's logs
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assetlog()
{
return $this->hasMany(\App\Models\Actionlog::class, 'item_id')
- ->where('item_type', '=', self::class)
- ->orderBy('created_at', 'desc')
- ->withTrashed();
+ ->where('item_type', '=', self::class)
+ ->orderBy('created_at', 'desc')
+ ->withTrashed();
}
/**
* Get the list of checkouts for this asset
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function checkouts()
@@ -681,7 +684,7 @@ class Asset extends Depreciable
* Get the list of audits for this asset
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function audits()
@@ -695,7 +698,7 @@ class Asset extends Depreciable
* Get the list of checkins for this asset
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function checkins()
@@ -710,7 +713,7 @@ class Asset extends Depreciable
* Get the asset's user requests
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function userRequests()
@@ -725,21 +728,21 @@ class Asset extends Depreciable
/**
* Get maintenances for this asset
*
- * @author Vincent Sposato <[email protected]>
- * @since 1.0
+ * @author Vincent Sposato <[email protected]>
+ * @since 1.0
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assetmaintenances()
{
return $this->hasMany(\App\Models\AssetMaintenance::class, 'asset_id')
- ->orderBy('created_at', 'desc');
+ ->orderBy('created_at', 'desc');
}
/**
* Get user who created the item
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function adminuser()
@@ -753,7 +756,7 @@ class Asset extends Depreciable
* Establishes the asset -> status relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assetstatus()
@@ -765,7 +768,7 @@ class Asset extends Depreciable
* Establishes the asset -> model relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function model()
@@ -776,9 +779,9 @@ class Asset extends Depreciable
/**
* Return the assets with a warranty expiring within x days
*
- * @param $days
+ * @param $days
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return mixed
*/
public static function getExpiringWarrantee($days = 30)
@@ -790,9 +793,11 @@ class Asset extends Depreciable
->whereNotNull('purchase_date')
->whereNull('deleted_at')
->NotArchived()
- ->whereRaw('DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) <= DATE_ADD(NOW(), INTERVAL '
+ ->whereRaw(
+ 'DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) <= DATE_ADD(NOW(), INTERVAL '
. $days
- . ' DAY) AND DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) > NOW()')
+ . ' DAY) AND DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) > NOW()'
+ )
->orderByRaw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH)')
->get();
}
@@ -802,7 +807,7 @@ class Asset extends Depreciable
* Establishes the asset -> assigned licenses relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function licenses()
@@ -814,7 +819,7 @@ class Asset extends Depreciable
* Establishes the asset -> license seats relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function licenseseats()
@@ -826,7 +831,7 @@ class Asset extends Depreciable
* Establishes the asset -> aupplier relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function supplier()
@@ -838,7 +843,7 @@ class Asset extends Depreciable
* Establishes the asset -> location relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function location()
@@ -851,7 +856,7 @@ class Asset extends Depreciable
* Get the next autoincremented asset tag
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return string | false
*/
public static function autoincrement_asset(int $additional_increment = 0)
@@ -877,7 +882,7 @@ class Asset extends Depreciable
* We'll add the zerofill and prefixes on the fly as we generate the number.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return int
*/
public static function nextAutoIncrement($assets)
@@ -888,12 +893,10 @@ class Asset extends Depreciable
foreach ($assets as $asset) {
$results = preg_match("/\d+$/", $asset['asset_tag'], $matches);
- if ($results)
- {
+ if ($results) {
$number = $matches[0];
- if ($number > $max)
- {
+ if ($number > $max) {
$max = $number;
}
}
@@ -910,7 +913,7 @@ class Asset extends Depreciable
* We'll add the zerofill and prefixes on the fly as we generate the number.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return string
*/
public static function zerofill($num, $zerofill = 3)
@@ -923,7 +926,7 @@ class Asset extends Depreciable
* asset model category
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return bool
*/
public function checkin_email()
@@ -937,7 +940,7 @@ class Asset extends Depreciable
* Determine whether this asset requires acceptance by the assigned user
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return bool
*/
public function requireAcceptance()
@@ -954,7 +957,7 @@ class Asset extends Depreciable
* Determine whether this asset's next audit date is before the last audit date
*
* @return bool
- * @since [v6.4.1]
+ * @since [v6.4.1]
* @author [A. Gianotto] [<[email protected]>]
* */
public function checkInvalidNextAuditDate()
@@ -982,7 +985,7 @@ class Asset extends Depreciable
* checks for a settings level EULA
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return string | false
*/
public function getEula()
@@ -1001,7 +1004,8 @@ class Asset extends Depreciable
return false;
}
- public function getComponentCost(){
+ public function getComponentCost()
+ {
$cost = 0;
foreach($this->components as $component) {
$cost += $component->pivot->assigned_qty*$component->purchase_cost;
@@ -1021,7 +1025,7 @@ class Asset extends Depreciable
* This is kind of dumb and confusing, since we already cast it that way AND it's a date field
* in the database, but here we are.
*
- * @param $value
+ * @param $value
* @return void
*/
@@ -1071,7 +1075,7 @@ class Asset extends Depreciable
*
* This will also correctly parse a 1/0 if "true"/"false" is passed.
*
- * @param $value
+ * @param $value
* @return void
*/
@@ -1085,16 +1089,16 @@ class Asset extends Depreciable
/**
- * -----------------------------------------------
- * BEGIN QUERY SCOPES
- * -----------------------------------------------
- **/
+ * -----------------------------------------------
+ * BEGIN QUERY SCOPES
+ * -----------------------------------------------
+ **/
/**
* Run additional, advanced searches.
*
* @param \Illuminate\Database\Eloquent\Builder $query
- * @param array $terms The search terms
+ * @param array $terms The search terms
* @return \Illuminate\Database\Eloquent\Builder
*/
public function advancedTextSearch(Builder $query, array $terms)
@@ -1103,10 +1107,12 @@ class Asset extends Depreciable
/**
* Assigned user
*/
- $query = $query->leftJoin('users as assets_users', function ($leftJoin) {
- $leftJoin->on('assets_users.id', '=', 'assets.assigned_to')
- ->where('assets.assigned_type', '=', User::class);
- });
+ $query = $query->leftJoin(
+ 'users as assets_users', function ($leftJoin) {
+ $leftJoin->on('assets_users.id', '=', 'assets.assigned_to')
+ ->where('assets.assigned_type', '=', User::class);
+ }
+ );
foreach ($terms as $term) {
@@ -1116,19 +1122,23 @@ class Asset extends Depreciable
->orWhere('assets_users.jobtitle', 'LIKE', '%'.$term.'%')
->orWhere('assets_users.username', 'LIKE', '%'.$term.'%')
->orWhere('assets_users.employee_num', 'LIKE', '%'.$term.'%')
- ->orWhereMultipleColumns([
+ ->orWhereMultipleColumns(
+ [
'assets_users.first_name',
'assets_users.last_name',
- ], $term);
+ ], $term
+ );
}
/**
* Assigned location
*/
- $query = $query->leftJoin('locations as assets_locations', function ($leftJoin) {
- $leftJoin->on('assets_locations.id', '=', 'assets.assigned_to')
- ->where('assets.assigned_type', '=', Location::class);
- });
+ $query = $query->leftJoin(
+ 'locations as assets_locations', function ($leftJoin) {
+ $leftJoin->on('assets_locations.id', '=', 'assets.assigned_to')
+ ->where('assets.assigned_type', '=', Location::class);
+ }
+ );
foreach ($terms as $term) {
@@ -1138,10 +1148,12 @@ class Asset extends Depreciable
/**
* Assigned assets
*/
- $query = $query->leftJoin('assets as assigned_assets', function ($leftJoin) {
- $leftJoin->on('assigned_assets.id', '=', 'assets.assigned_to')
- ->where('assets.assigned_type', '=', self::class);
- });
+ $query = $query->leftJoin(
+ 'assets as assigned_assets', function ($leftJoin) {
+ $leftJoin->on('assigned_assets.id', '=', 'assets.assigned_to')
+ ->where('assets.assigned_type', '=', self::class);
+ }
+ );
foreach ($terms as $term) {
$query = $query->orWhere('assigned_assets.name', 'LIKE', '%'.$term.'%');
@@ -1153,12 +1165,12 @@ class Asset extends Depreciable
/**
- * Query builder scope for hardware
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ * Query builder scope for hardware
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeHardware($query)
{
@@ -1166,101 +1178,121 @@ class Asset extends Depreciable
}
/**
- * Query builder scope for pending assets
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ * Query builder scope for pending assets
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopePending($query)
{
- return $query->whereHas('assetstatus', function ($query) {
- $query->where('deployable', '=', 0)
- ->where('pending', '=', 1)
- ->where('archived', '=', 0);
- });
+ return $query->whereHas(
+ 'assetstatus', function ($query) {
+ $query->where('deployable', '=', 0)
+ ->where('pending', '=', 1)
+ ->where('archived', '=', 0);
+ }
+ );
}
/**
- * Query builder scope for searching location
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ * Query builder scope for searching location
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeAssetsByLocation($query, $location)
{
- return $query->where(function ($query) use ($location) {
- $query->whereHas('assignedTo', function ($query) use ($location) {
- $query->where([
- ['users.location_id', '=', $location->id],
- ['assets.assigned_type', '=', User::class],
- ])->orWhere([
- ['locations.id', '=', $location->id],
- ['assets.assigned_type', '=', Location::class],
- ])->orWhere([
- ['assets.rtd_location_id', '=', $location->id],
- ['assets.assigned_type', '=', self::class],
- ]);
- })->orWhere(function ($query) use ($location) {
- $query->where('assets.rtd_location_id', '=', $location->id);
- $query->whereNull('assets.assigned_to');
- });
- });
- }
-
-
- /**
- * Query builder scope for RTD assets
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ return $query->where(
+ function ($query) use ($location) {
+ $query->whereHas(
+ 'assignedTo', function ($query) use ($location) {
+ $query->where(
+ [
+ ['users.location_id', '=', $location->id],
+ ['assets.assigned_type', '=', User::class],
+ ]
+ )->orWhere(
+ [
+ ['locations.id', '=', $location->id],
+ ['assets.assigned_type', '=', Location::class],
+ ]
+ )->orWhere(
+ [
+ ['assets.rtd_location_id', '=', $location->id],
+ ['assets.assigned_type', '=', self::class],
+ ]
+ );
+ }
+ )->orWhere(
+ function ($query) use ($location) {
+ $query->where('assets.rtd_location_id', '=', $location->id);
+ $query->whereNull('assets.assigned_to');
+ }
+ );
+ }
+ );
+ }
+
+
+ /**
+ * Query builder scope for RTD assets
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeRTD($query)
{
return $query->whereNull('assets.assigned_to')
- ->whereHas('assetstatus', function ($query) {
- $query->where('deployable', '=', 1)
- ->where('pending', '=', 0)
- ->where('archived', '=', 0);
- });
+ ->whereHas(
+ 'assetstatus', function ($query) {
+ $query->where('deployable', '=', 1)
+ ->where('pending', '=', 0)
+ ->where('archived', '=', 0);
+ }
+ );
}
- /**
- * Query builder scope for Undeployable assets
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ /**
+ * Query builder scope for Undeployable assets
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeUndeployable($query)
{
- return $query->whereHas('assetstatus', function ($query) {
- $query->where('deployable', '=', 0)
- ->where('pending', '=', 0)
- ->where('archived', '=', 0);
- });
+ return $query->whereHas(
+ 'assetstatus', function ($query) {
+ $query->where('deployable', '=', 0)
+ ->where('pending', '=', 0)
+ ->where('archived', '=', 0);
+ }
+ );
}
/**
* Query builder scope for non-Archived assets
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
public function scopeNotArchived($query)
{
- return $query->whereHas('assetstatus', function ($query) {
- $query->where('archived', '=', 0);
- });
+ return $query->whereHas(
+ 'assetstatus', function ($query) {
+ $query->where('archived', '=', 0);
+ }
+ );
}
/**
@@ -1280,8 +1312,8 @@ class Asset extends Depreciable
* now = May 4, 2019
*
* @author A. Gianotto <[email protected]>
- * @since v4.6.16
- * @param Setting $settings
+ * @since v4.6.16
+ * @param Setting $settings
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -1306,8 +1338,8 @@ class Asset extends Depreciable
* for an upcoming API call for retrieving a report on overdue assets.
*
* @author A. Gianotto <[email protected]>
- * @since v4.6.16
- * @param Setting $settings
+ * @since v4.6.16
+ * @param Setting $settings
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -1328,8 +1360,8 @@ class Asset extends Depreciable
* for an upcoming API call for retrieving a report on assets that will need to be audited.
*
* @author A. Gianotto <[email protected]>
- * @since v4.6.16
- * @param Setting $settings
+ * @since v4.6.16
+ * @param Setting $settings
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -1337,11 +1369,15 @@ class Asset extends Depreciable
public function scopeDueOrOverdueForAudit($query, $settings)
{
- return $query->where(function ($query) {
- $query->OverdueForAudit();
- })->orWhere(function ($query) use ($settings) {
- $query->DueForAudit($settings);
- });
+ return $query->where(
+ function ($query) {
+ $query->OverdueForAudit();
+ }
+ )->orWhere(
+ function ($query) use ($settings) {
+ $query->DueForAudit($settings);
+ }
+ );
}
@@ -1350,7 +1386,7 @@ class Asset extends Depreciable
* and settings.audit_warning_days. It checks to see if assets.expected_checkin is now
*
* @author A. Gianotto <[email protected]>
- * @since v6.4.0
+ * @since v6.4.0
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -1371,7 +1407,7 @@ class Asset extends Depreciable
* Query builder scope for Assets that are overdue for checkin OR overdue
*
* @author A. Gianotto <[email protected]>
- * @since v6.4.0
+ * @since v6.4.0
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
public function scopeOverdueForCheckin($query)
@@ -1387,16 +1423,20 @@ class Asset extends Depreciable
* Query builder scope for Assets that are due for checkin OR overdue
*
* @author A. Gianotto <[email protected]>
- * @since v6.4.0
+ * @since v6.4.0
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
public function scopeDueOrOverdueForCheckin($query, $settings)
{
- return $query->where(function ($query) {
- $query->OverdueForCheckin();
- })->orWhere(function ($query) use ($settings) {
- $query->DueForCheckin($settings);
- });
+ return $query->where(
+ function ($query) {
+ $query->OverdueForCheckin();
+ }
+ )->orWhere(
+ function ($query) use ($settings) {
+ $query->DueForCheckin($settings);
+ }
+ );
}
@@ -1407,7 +1447,7 @@ class Asset extends Depreciable
* has chosen to not display archived assets in their regular lists
* and views, it will return the correct number.
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -1416,115 +1456,123 @@ class Asset extends Depreciable
{
if (Setting::getSettings()->show_archived_in_list!=1) {
- return $query->whereHas('assetstatus', function ($query) {
- $query->where('archived', '=', 0);
- });
+ return $query->whereHas(
+ 'assetstatus', function ($query) {
+ $query->where('archived', '=', 0);
+ }
+ );
} else {
return $query;
}
}
- /**
- * Query builder scope for Archived assets
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ /**
+ * Query builder scope for Archived assets
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeArchived($query)
{
- return $query->whereHas('assetstatus', function ($query) {
- $query->where('deployable', '=', 0)
- ->where('pending', '=', 0)
- ->where('archived', '=', 1);
- });
+ return $query->whereHas(
+ 'assetstatus', function ($query) {
+ $query->where('deployable', '=', 0)
+ ->where('pending', '=', 0)
+ ->where('archived', '=', 1);
+ }
+ );
}
- /**
- * Query builder scope for Deployed assets
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ /**
+ * Query builder scope for Deployed assets
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeDeployed($query)
{
return $query->where('assigned_to', '>', '0');
}
- /**
- * Query builder scope for Requestable assets
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ /**
+ * Query builder scope for Requestable assets
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeRequestableAssets($query): Builder
{
$table = $query->getModel()->getTable();
return Company::scopeCompanyables($query->where($table.'.requestable', '=', 1))
- ->whereHas('assetstatus', function ($query) {
- $query->where(function ($query) {
- $query->where('deployable', '=', 1)
- ->where('archived', '=', 0); // you definitely can't request something that's archived
- })->orWhere('pending', '=', 1); // we've decided that even though an asset may be 'pending', you can still request it
- });
- }
-
-
- /**
- * scopeInModelList
- * Get all assets in the provided listing of model ids
- *
- * @param $query
- * @param array $modelIdListing
- *
- * @return mixed
- * @author Vincent Sposato <[email protected]>
- * @version v1.0
- */
+ ->whereHas(
+ 'assetstatus', function ($query) {
+ $query->where(
+ function ($query) {
+ $query->where('deployable', '=', 1)
+ ->where('archived', '=', 0); // you definitely can't request something that's archived
+ }
+ )->orWhere('pending', '=', 1); // we've decided that even though an asset may be 'pending', you can still request it
+ }
+ );
+ }
+
+
+ /**
+ * scopeInModelList
+ * Get all assets in the provided listing of model ids
+ *
+ * @param $query
+ * @param array $modelIdListing
+ *
+ * @return mixed
+ * @author Vincent Sposato <[email protected]>
+ * @version v1.0
+ */
public function scopeInModelList($query, array $modelIdListing)
{
return $query->whereIn('assets.model_id', $modelIdListing);
}
- /**
- * Query builder scope to get not-yet-accepted assets
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ /**
+ * Query builder scope to get not-yet-accepted assets
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeNotYetAccepted($query)
{
return $query->where('accepted', '=', 'pending');
}
- /**
- * Query builder scope to get rejected assets
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ /**
+ * Query builder scope to get rejected assets
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeRejected($query)
{
return $query->where('accepted', '=', 'rejected');
}
- /**
- * Query builder scope to get accepted assets
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ /**
+ * Query builder scope to get accepted assets
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeAccepted($query)
{
return $query->where('accepted', '=', 'accepted');
@@ -1533,8 +1581,8 @@ class Asset extends Depreciable
/**
* Query builder scope to search on text for complex Bootstrap Tables API.
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $search Search term
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $search Search term
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -1542,71 +1590,99 @@ class Asset extends Depreciable
{
$search = explode(' OR ', $search);
- return $query->leftJoin('users as assets_users', function ($leftJoin) {
- $leftJoin->on('assets_users.id', '=', 'assets.assigned_to')
- ->where('assets.assigned_type', '=', User::class);
- })->leftJoin('locations as assets_locations', function ($leftJoin) {
- $leftJoin->on('assets_locations.id', '=', 'assets.assigned_to')
- ->where('assets.assigned_type', '=', Location::class);
- })->leftJoin('assets as assigned_assets', function ($leftJoin) {
- $leftJoin->on('assigned_assets.id', '=', 'assets.assigned_to')
- ->where('assets.assigned_type', '=', self::class);
- })->where(function ($query) use ($search) {
- foreach ($search as $search) {
- $query->whereHas('model', function ($query) use ($search) {
- $query->whereHas('category', function ($query) use ($search) {
- $query->where(function ($query) use ($search) {
- $query->where('categories.name', 'LIKE', '%'.$search.'%')
- ->orWhere('models.name', 'LIKE', '%'.$search.'%')
- ->orWhere('models.model_number', 'LIKE', '%'.$search.'%');
- });
- });
- })->orWhereHas('model', function ($query) use ($search) {
- $query->whereHas('manufacturer', function ($query) use ($search) {
- $query->where(function ($query) use ($search) {
- $query->where('manufacturers.name', 'LIKE', '%'.$search.'%');
- });
- });
- })->orWhere(function ($query) use ($search) {
- $query->where('assets_users.first_name', 'LIKE', '%'.$search.'%')
- ->orWhere('assets_users.last_name', 'LIKE', '%'.$search.'%')
- ->orWhere('assets_users.username', 'LIKE', '%'.$search.'%')
- ->orWhere('assets_users.jobtitle', 'LIKE', '%'.$search.'%')
- ->orWhereMultipleColumns([
- 'assets_users.first_name',
- 'assets_users.last_name',
- 'assets_users.jobtitle',
- ], $search)
- ->orWhere('assets_locations.name', 'LIKE', '%'.$search.'%')
- ->orWhere('assigned_assets.name', 'LIKE', '%'.$search.'%');
- })->orWhere('assets.name', 'LIKE', '%'.$search.'%')
- ->orWhere('assets.asset_tag', 'LIKE', '%'.$search.'%')
- ->orWhere('assets.serial', 'LIKE', '%'.$search.'%')
- ->orWhere('assets.order_number', 'LIKE', '%'.$search.'%')
- ->orWhere('assets.notes', 'LIKE', '%'.$search.'%');
+ return $query->leftJoin(
+ 'users as assets_users', function ($leftJoin) {
+ $leftJoin->on('assets_users.id', '=', 'assets.assigned_to')
+ ->where('assets.assigned_type', '=', User::class);
+ }
+ )->leftJoin(
+ 'locations as assets_locations', function ($leftJoin) {
+ $leftJoin->on('assets_locations.id', '=', 'assets.assigned_to')
+ ->where('assets.assigned_type', '=', Location::class);
}
+ )->leftJoin(
+ 'assets as assigned_assets', function ($leftJoin) {
+ $leftJoin->on('assigned_assets.id', '=', 'assets.assigned_to')
+ ->where('assets.assigned_type', '=', self::class);
+ }
+ )->where(
+ function ($query) use ($search) {
+ foreach ($search as $search) {
+ $query->whereHas(
+ 'model', function ($query) use ($search) {
+ $query->whereHas(
+ 'category', function ($query) use ($search) {
+ $query->where(
+ function ($query) use ($search) {
+ $query->where('categories.name', 'LIKE', '%'.$search.'%')
+ ->orWhere('models.name', 'LIKE', '%'.$search.'%')
+ ->orWhere('models.model_number', 'LIKE', '%'.$search.'%');
+ }
+ );
+ }
+ );
+ }
+ )->orWhereHas(
+ 'model', function ($query) use ($search) {
+ $query->whereHas(
+ 'manufacturer', function ($query) use ($search) {
+ $query->where(
+ function ($query) use ($search) {
+ $query->where('manufacturers.name', 'LIKE', '%'.$search.'%');
+ }
+ );
+ }
+ );
+ }
+ )->orWhere(
+ function ($query) use ($search) {
+ $query->where('assets_users.first_name', 'LIKE', '%'.$search.'%')
+ ->orWhere('assets_users.last_name', 'LIKE', '%'.$search.'%')
+ ->orWhere('assets_users.username', 'LIKE', '%'.$search.'%')
+ ->orWhere('assets_users.jobtitle', 'LIKE', '%'.$search.'%')
+ ->orWhereMultipleColumns(
+ [
+ 'assets_users.first_name',
+ 'assets_users.last_name',
+ 'assets_users.jobtitle',
+ ], $search
+ )
+ ->orWhere('assets_locations.name', 'LIKE', '%'.$search.'%')
+ ->orWhere('assigned_assets.name', 'LIKE', '%'.$search.'%');
+ }
+ )->orWhere('assets.name', 'LIKE', '%'.$search.'%')
+ ->orWhere('assets.asset_tag', 'LIKE', '%'.$search.'%')
+ ->orWhere('assets.serial', 'LIKE', '%'.$search.'%')
+ ->orWhere('assets.order_number', 'LIKE', '%'.$search.'%')
+ ->orWhere('assets.notes', 'LIKE', '%'.$search.'%');
+ }
- })->withTrashed()->whereNull('assets.deleted_at'); //workaround for laravel bug
+ }
+ )->withTrashed()->whereNull('assets.deleted_at'); //workaround for laravel bug
}
/**
* Query builder scope to search the department ID of users assigned to assets
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v5.0]
+ * @since [v5.0]
* @return string | false
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
public function scopeCheckedOutToTargetInDepartment($query, $search)
{
- return $query->leftJoin('users as assets_dept_users', function ($leftJoin) {
- $leftJoin->on('assets_dept_users.id', '=', 'assets.assigned_to')
- ->where('assets.assigned_type', '=', User::class);
- })->where(function ($query) use ($search) {
+ return $query->leftJoin(
+ 'users as assets_dept_users', function ($leftJoin) {
+ $leftJoin->on('assets_dept_users.id', '=', 'assets.assigned_to')
+ ->where('assets.assigned_type', '=', User::class);
+ }
+ )->where(
+ function ($query) use ($search) {
$query->whereIn('assets_dept_users.department_id', $search);
- })->withTrashed()->whereNull('assets.deleted_at'); //workaround for laravel bug
+ }
+ )->withTrashed()->whereNull('assets.deleted_at'); //workaround for laravel bug
}
@@ -1614,189 +1690,229 @@ class Asset extends Depreciable
/**
* Query builder scope to search on text filters for complex Bootstrap Tables API
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $filter JSON array of search keys and terms
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $filter JSON array of search keys and terms
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
public function scopeByFilter($query, $filter)
{
- return $query->where(function ($query) use ($filter) {
- foreach ($filter as $key => $search_val) {
+ return $query->where(
+ function ($query) use ($filter) {
+ foreach ($filter as $key => $search_val) {
- $fieldname = str_replace('custom_fields.', '', $key);
+ $fieldname = str_replace('custom_fields.', '', $key);
- if ($fieldname == 'asset_tag') {
- $query->where('assets.asset_tag', 'LIKE', '%'.$search_val.'%');
- }
+ if ($fieldname == 'asset_tag') {
+ $query->where('assets.asset_tag', 'LIKE', '%'.$search_val.'%');
+ }
- if ($fieldname == 'name') {
- $query->where('assets.name', 'LIKE', '%'.$search_val.'%');
- }
+ if ($fieldname == 'name') {
+ $query->where('assets.name', 'LIKE', '%'.$search_val.'%');
+ }
- if ($fieldname =='serial') {
- $query->where('assets.serial', 'LIKE', '%'.$search_val.'%');
- }
+ if ($fieldname =='serial') {
+ $query->where('assets.serial', 'LIKE', '%'.$search_val.'%');
+ }
- if ($fieldname == 'purchase_date') {
- $query->where('assets.purchase_date', 'LIKE', '%'.$search_val.'%');
- }
+ if ($fieldname == 'purchase_date') {
+ $query->where('assets.purchase_date', 'LIKE', '%'.$search_val.'%');
+ }
- if ($fieldname == 'purchase_cost') {
- $query->where('assets.purchase_cost', 'LIKE', '%'.$search_val.'%');
- }
+ if ($fieldname == 'purchase_cost') {
+ $query->where('assets.purchase_cost', 'LIKE', '%'.$search_val.'%');
+ }
- if ($fieldname == 'notes') {
- $query->where('assets.notes', 'LIKE', '%'.$search_val.'%');
- }
+ if ($fieldname == 'notes') {
+ $query->where('assets.notes', 'LIKE', '%'.$search_val.'%');
+ }
- if ($fieldname == 'order_number') {
- $query->where('assets.order_number', 'LIKE', '%'.$search_val.'%');
- }
+ if ($fieldname == 'order_number') {
+ $query->where('assets.order_number', 'LIKE', '%'.$search_val.'%');
+ }
- if ($fieldname == 'status_label') {
- $query->whereHas('assetstatus', function ($query) use ($search_val) {
- $query->where('status_labels.name', 'LIKE', '%'.$search_val.'%');
- });
- }
+ if ($fieldname == 'status_label') {
+ $query->whereHas(
+ 'assetstatus', function ($query) use ($search_val) {
+ $query->where('status_labels.name', 'LIKE', '%'.$search_val.'%');
+ }
+ );
+ }
- if ($fieldname == 'location') {
- $query->whereHas('location', function ($query) use ($search_val) {
- $query->where('locations.name', 'LIKE', '%'.$search_val.'%');
- });
- }
+ if ($fieldname == 'location') {
+ $query->whereHas(
+ 'location', function ($query) use ($search_val) {
+ $query->where('locations.name', 'LIKE', '%'.$search_val.'%');
+ }
+ );
+ }
- if ($fieldname == 'rtd_location') {
- $query->whereHas('defaultLoc', function ($query) use ($search_val) {
- $query->where('locations.name', 'LIKE', '%'.$search_val.'%');
- });
- }
+ if ($fieldname == 'rtd_location') {
+ $query->whereHas(
+ 'defaultLoc', function ($query) use ($search_val) {
+ $query->where('locations.name', 'LIKE', '%'.$search_val.'%');
+ }
+ );
+ }
- if ($fieldname =='assigned_to') {
- $query->whereHasMorph('assignedTo', [User::class], function ($query) use ($search_val) {
- $query->where(function ($query) use ($search_val) {
- $query->where('users.first_name', 'LIKE', '%'.$search_val.'%')
- ->orWhere('users.last_name', 'LIKE', '%'.$search_val.'%');
- });
- });
- }
+ if ($fieldname =='assigned_to') {
+ $query->whereHasMorph(
+ 'assignedTo', [User::class], function ($query) use ($search_val) {
+ $query->where(
+ function ($query) use ($search_val) {
+ $query->where('users.first_name', 'LIKE', '%'.$search_val.'%')
+ ->orWhere('users.last_name', 'LIKE', '%'.$search_val.'%');
+ }
+ );
+ }
+ );
+ }
- if ($fieldname == 'manufacturer') {
- $query->whereHas('model', function ($query) use ($search_val) {
- $query->whereHas('manufacturer', function ($query) use ($search_val) {
- $query->where(function ($query) use ($search_val) {
- $query->where('manufacturers.name', 'LIKE', '%'.$search_val.'%');
- });
- });
- });
- }
+ if ($fieldname == 'manufacturer') {
+ $query->whereHas(
+ 'model', function ($query) use ($search_val) {
+ $query->whereHas(
+ 'manufacturer', function ($query) use ($search_val) {
+ $query->where(
+ function ($query) use ($search_val) {
+ $query->where('manufacturers.name', 'LIKE', '%'.$search_val.'%');
+ }
+ );
+ }
+ );
+ }
+ );
+ }
- if ($fieldname == 'category') {
- $query->whereHas('model', function ($query) use ($search_val) {
- $query->whereHas('category', function ($query) use ($search_val) {
- $query->where(function ($query) use ($search_val) {
- $query->where('categories.name', 'LIKE', '%'.$search_val.'%')
- ->orWhere('models.name', 'LIKE', '%'.$search_val.'%')
- ->orWhere('models.model_number', 'LIKE', '%'.$search_val.'%');
- });
- });
- });
- }
+ if ($fieldname == 'category') {
+ $query->whereHas(
+ 'model', function ($query) use ($search_val) {
+ $query->whereHas(
+ 'category', function ($query) use ($search_val) {
+ $query->where(
+ function ($query) use ($search_val) {
+ $query->where('categories.name', 'LIKE', '%'.$search_val.'%')
+ ->orWhere('models.name', 'LIKE', '%'.$search_val.'%')
+ ->orWhere('models.model_number', 'LIKE', '%'.$search_val.'%');
+ }
+ );
+ }
+ );
+ }
+ );
+ }
- if ($fieldname == 'model') {
- $query->where(function ($query) use ($search_val) {
- $query->whereHas('model', function ($query) use ($search_val) {
- $query->where('models.name', 'LIKE', '%'.$search_val.'%');
- });
- });
- }
+ if ($fieldname == 'model') {
+ $query->where(
+ function ($query) use ($search_val) {
+ $query->whereHas(
+ 'model', function ($query) use ($search_val) {
+ $query->where('models.name', 'LIKE', '%'.$search_val.'%');
+ }
+ );
+ }
+ );
+ }
- if ($fieldname == 'model_number') {
- $query->where(function ($query) use ($search_val) {
- $query->whereHas('model', function ($query) use ($search_val) {
- $query->where('models.model_number', 'LIKE', '%'.$search_val.'%');
- });
- });
- }
+ if ($fieldname == 'model_number') {
+ $query->where(
+ function ($query) use ($search_val) {
+ $query->whereHas(
+ 'model', function ($query) use ($search_val) {
+ $query->where('models.model_number', 'LIKE', '%'.$search_val.'%');
+ }
+ );
+ }
+ );
+ }
- if ($fieldname == 'company') {
- $query->where(function ($query) use ($search_val) {
- $query->whereHas('company', function ($query) use ($search_val) {
- $query->where('companies.name', 'LIKE', '%'.$search_val.'%');
- });
- });
- }
+ if ($fieldname == 'company') {
+ $query->where(
+ function ($query) use ($search_val) {
+ $query->whereHas(
+ 'company', function ($query) use ($search_val) {
+ $query->where('companies.name', 'LIKE', '%'.$search_val.'%');
+ }
+ );
+ }
+ );
+ }
- if ($fieldname == 'supplier') {
- $query->where(function ($query) use ($search_val) {
- $query->whereHas('supplier', function ($query) use ($search_val) {
- $query->where('suppliers.name', 'LIKE', '%'.$search_val.'%');
- });
- });
- }
+ if ($fieldname == 'supplier') {
+ $query->where(
+ function ($query) use ($search_val) {
+ $query->whereHas(
+ 'supplier', function ($query) use ($search_val) {
+ $query->where('suppliers.name', 'LIKE', '%'.$search_val.'%');
+ }
+ );
+ }
+ );
+ }
- /**
- * THIS CLUNKY BIT IS VERY IMPORTANT
- *
- * Although inelegant, this section matters a lot when querying against fields that do not
- * exist on the asset table. There's probably a better way to do this moving forward, for
- * example using the Schema:: methods to determine whether or not a column actually exists,
- * or even just using the $searchableRelations variable earlier in this file.
- *
- * In short, this set of statements tells the query builder to ONLY query against an
- * actual field that's being passed if it doesn't meet known relational fields. This
- * allows us to query custom fields directly in the assets table
- * (regardless of their name) and *skip* any fields that we already know can only be
- * searched through relational searches that we do earlier in this method.
- *
- * For example, we do not store "location" as a field on the assets table, we store
- * that relationship through location_id on the assets table, therefore querying
- * assets.location would fail, as that field doesn't exist -- plus we're already searching
- * against those relationships earlier in this method.
- *
- * - snipe
- *
- */
-
- if (($fieldname!='category') && ($fieldname!='model_number') && ($fieldname!='rtd_location') && ($fieldname!='location') && ($fieldname!='supplier')
- && ($fieldname!='status_label') && ($fieldname!='assigned_to') && ($fieldname!='model') && ($fieldname!='company') && ($fieldname!='manufacturer')) {
- $query->where('assets.'.$fieldname, 'LIKE', '%' . $search_val . '%');
- }
+ /**
+ * THIS CLUNKY BIT IS VERY IMPORTANT
+ *
+ * Although inelegant, this section matters a lot when querying against fields that do not
+ * exist on the asset table. There's probably a better way to do this moving forward, for
+ * example using the Schema:: methods to determine whether or not a column actually exists,
+ * or even just using the $searchableRelations variable earlier in this file.
+ *
+ * In short, this set of statements tells the query builder to ONLY query against an
+ * actual field that's being passed if it doesn't meet known relational fields. This
+ * allows us to query custom fields directly in the assets table
+ * (regardless of their name) and *skip* any fields that we already know can only be
+ * searched through relational searches that we do earlier in this method.
+ *
+ * For example, we do not store "location" as a field on the assets table, we store
+ * that relationship through location_id on the assets table, therefore querying
+ * assets.location would fail, as that field doesn't exist -- plus we're already searching
+ * against those relationships earlier in this method.
+ *
+ * - snipe
+ */
+
+ if (($fieldname!='category') && ($fieldname!='model_number') && ($fieldname!='rtd_location') && ($fieldname!='location') && ($fieldname!='supplier')
+ && ($fieldname!='status_label') && ($fieldname!='assigned_to') && ($fieldname!='model') && ($fieldname!='company') && ($fieldname!='manufacturer')
+ ) {
+ $query->where('assets.'.$fieldname, 'LIKE', '%' . $search_val . '%');
+ }
- }
+ }
- });
+ }
+ );
}
/**
- * Query builder scope to order on model
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ * Query builder scope to order on model
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeOrderModels($query, $order)
{
return $query->join('models as asset_models', 'assets.model_id', '=', 'asset_models.id')->orderBy('asset_models.name', $order);
}
/**
- * Query builder scope to order on model number
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ * Query builder scope to order on model number
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeOrderModelNumber($query, $order)
{
return $query->leftJoin('models as model_number_sort', 'assets.model_id', '=', 'model_number_sort.id')->orderBy('model_number_sort.model_number', $order);
@@ -1806,8 +1922,8 @@ class Asset extends Depreciable
/**
* Query builder scope to order on created_by name
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -1818,39 +1934,39 @@ class Asset extends Depreciable
/**
- * Query builder scope to order on assigned user
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ * Query builder scope to order on assigned user
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeOrderAssigned($query, $order)
{
return $query->leftJoin('users as users_sort', 'assets.assigned_to', '=', 'users_sort.id')->select('assets.*')->orderBy('users_sort.first_name', $order)->orderBy('users_sort.last_name', $order);
}
/**
- * Query builder scope to order on status
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ * Query builder scope to order on status
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeOrderStatus($query, $order)
{
return $query->join('status_labels as status_sort', 'assets.status_id', '=', 'status_sort.id')->orderBy('status_sort.name', $order);
}
/**
- * Query builder scope to order on company
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ * Query builder scope to order on company
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeOrderCompany($query, $order)
{
return $query->leftJoin('companies as company_sort', 'assets.company_id', '=', 'company_sort.id')->orderBy('company_sort.name', $order);
@@ -1860,8 +1976,8 @@ class Asset extends Depreciable
/**
* Query builder scope to return results of a category
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -1869,34 +1985,34 @@ class Asset extends Depreciable
{
return $query->join('models as category_models', 'assets.model_id', '=', 'category_models.id')
->join('categories', 'category_models.category_id', '=', 'categories.id')
- ->whereIn('category_models.category_id', (!is_array($category_id) ? explode(',',$category_id): $category_id));
+ ->whereIn('category_models.category_id', (!is_array($category_id) ? explode(',', $category_id): $category_id));
//->whereIn('category_models.category_id', $category_id);
}
/**
* Query builder scope to return results of a manufacturer
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
public function scopeByManufacturer($query, $manufacturer_id)
{
return $query->join('models', 'assets.model_id', '=', 'models.id')
- ->join('manufacturers', 'models.manufacturer_id', '=', 'manufacturers.id')->whereIn('models.manufacturer_id', (!is_array($manufacturer_id) ? explode(',',$manufacturer_id): $manufacturer_id));
+ ->join('manufacturers', 'models.manufacturer_id', '=', 'manufacturers.id')->whereIn('models.manufacturer_id', (!is_array($manufacturer_id) ? explode(',', $manufacturer_id): $manufacturer_id));
}
/**
- * Query builder scope to order on category
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ * Query builder scope to order on category
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeOrderCategory($query, $order)
{
return $query->join('models as order_model_category', 'assets.model_id', '=', 'order_model_category.id')
@@ -1908,8 +2024,8 @@ class Asset extends Depreciable
/**
* Query builder scope to order on manufacturer
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -1920,14 +2036,14 @@ class Asset extends Depreciable
->orderBy('manufacturer_order.name', $order);
}
- /**
- * Query builder scope to order on location
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ /**
+ * Query builder scope to order on location
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeOrderLocation($query, $order)
{
return $query->leftJoin('locations as asset_locations', 'asset_locations.id', '=', 'assets.location_id')->orderBy('asset_locations.name', $order);
@@ -1935,8 +2051,9 @@ class Asset extends Depreciable
/**
* Query builder scope to order on default
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -1949,8 +2066,8 @@ class Asset extends Depreciable
/**
* Query builder scope to order on supplier name
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -1962,8 +2079,8 @@ class Asset extends Depreciable
/**
* Query builder scope to order on supplier name
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -1975,26 +2092,31 @@ class Asset extends Depreciable
/**
* Query builder scope to search on location ID
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $search Search term
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $search Search term
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
public function scopeByLocationId($query, $search)
{
- return $query->where(function ($query) use ($search) {
- $query->whereHas('location', function ($query) use ($search) {
- $query->where('locations.id', '=', $search);
- });
- });
+ return $query->where(
+ function ($query) use ($search) {
+ $query->whereHas(
+ 'location', function ($query) use ($search) {
+ $query->where('locations.id', '=', $search);
+ }
+ );
+ }
+ );
}
/**
* Query builder scope to search on depreciation name
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $search Search term
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $search Search term
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
diff --git a/app/Models/AssetMaintenance.php b/app/Models/AssetMaintenance.php
index c838ab6b66..0699f83237 100644
--- a/app/Models/AssetMaintenance.php
+++ b/app/Models/AssetMaintenance.php
@@ -12,7 +12,7 @@ use Watson\Validating\ValidatingTrait;
/**
* Model for Asset Maintenances.
*
- * @version v1.0
+ * @version v1.0
*/
class AssetMaintenance extends Model implements ICompanyableChild
{
@@ -93,7 +93,7 @@ class AssetMaintenance extends Model implements ICompanyableChild
/**
* getImprovementOptions
*
- * @return array
+ * @return array
* @author Vincent Sposato <[email protected]>
* @version v1.0
*/
@@ -157,21 +157,21 @@ class AssetMaintenance extends Model implements ICompanyableChild
* asset
* Get asset for this improvement
*
- * @return mixed
+ * @return mixed
* @author Vincent Sposato <[email protected]>
* @version v1.0
*/
public function asset()
{
return $this->belongsTo(\App\Models\Asset::class, 'asset_id')
- ->withTrashed();
+ ->withTrashed();
}
/**
* Get the admin who created the maintenance
*
- * @return mixed
+ * @return mixed
* @author A. Gianotto <[email protected]>
* @version v3.0
*/
@@ -184,7 +184,7 @@ class AssetMaintenance extends Model implements ICompanyableChild
public function supplier()
{
return $this->belongsTo(\App\Models\Supplier::class, 'supplier_id')
- ->withTrashed();
+ ->withTrashed();
}
/**
@@ -196,8 +196,8 @@ class AssetMaintenance extends Model implements ICompanyableChild
/**
* Query builder scope to order on a supplier
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -212,8 +212,8 @@ class AssetMaintenance extends Model implements ICompanyableChild
/**
* Query builder scope to order on asset tag
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -226,8 +226,8 @@ class AssetMaintenance extends Model implements ICompanyableChild
/**
* Query builder scope to order on asset tag
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -240,8 +240,8 @@ class AssetMaintenance extends Model implements ICompanyableChild
/**
* Query builder scope to order on serial
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -254,8 +254,8 @@ class AssetMaintenance extends Model implements ICompanyableChild
/**
* Query builder scope to order on status label name
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -269,8 +269,8 @@ class AssetMaintenance extends Model implements ICompanyableChild
/**
* Query builder scope to order on status label name
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
diff --git a/app/Models/AssetModel.php b/app/Models/AssetModel.php
index ad236be8d9..bdb87d4f75 100755
--- a/app/Models/AssetModel.php
+++ b/app/Models/AssetModel.php
@@ -17,7 +17,7 @@ use App\Http\Traits\TwoColumnUniqueUndeletedTrait;
* Model for Asset Models. Asset Models contain higher level
* attributes that are common among the same type of asset.
*
- * @version v1.0
+ * @version v1.0
*/
class AssetModel extends SnipeModel
{
@@ -105,7 +105,7 @@ class AssetModel extends SnipeModel
* Establishes the model -> assets relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assets()
@@ -117,7 +117,7 @@ class AssetModel extends SnipeModel
* Establishes the model -> category relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function category()
@@ -129,7 +129,7 @@ class AssetModel extends SnipeModel
* Establishes the model -> depreciation relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function depreciation()
@@ -141,7 +141,7 @@ class AssetModel extends SnipeModel
* Establishes the model -> manufacturer relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function manufacturer()
@@ -153,7 +153,7 @@ class AssetModel extends SnipeModel
* Establishes the model -> fieldset relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function fieldset()
@@ -163,14 +163,14 @@ class AssetModel extends SnipeModel
public function customFields()
{
- return $this->fieldset()->first()->fields();
+ return $this->fieldset()->first()->fields();
}
/**
* Establishes the model -> custom field default values relationship
*
* @author hannah tinkler
- * @since [v4.3]
+ * @since [v4.3]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function defaultValues()
@@ -184,7 +184,7 @@ class AssetModel extends SnipeModel
* @todo this should probably be moved
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function getImageUrl()
@@ -201,7 +201,7 @@ class AssetModel extends SnipeModel
* Checks if the model is deletable
*
* @author A. Gianotto <[email protected]>
- * @since [v6.3.4]
+ * @since [v6.3.4]
* @return bool
*/
public function isDeletable()
@@ -216,7 +216,7 @@ class AssetModel extends SnipeModel
* Get user who created the item
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function adminuser()
@@ -235,10 +235,10 @@ class AssetModel extends SnipeModel
* scopeInCategory
* Get all models that are in the array of category ids
*
- * @param $query
+ * @param $query
* @param array $categoryIdListing
*
- * @return mixed
+ * @return mixed
* @author Vincent Sposato <[email protected]>
* @version v1.0
*/
@@ -251,9 +251,9 @@ class AssetModel extends SnipeModel
* scopeRequestable
* Get all models that are requestable by a user.
*
- * @param $query
+ * @param $query
*
- * @return $query
+ * @return $query
* @author Daniel Meltzer <[email protected]>
* @version v3.5
*/
@@ -265,8 +265,8 @@ class AssetModel extends SnipeModel
/**
* Query builder scope to search on text, including catgeory and manufacturer name
*
- * @param Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $search Search term
+ * @param Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $search Search term
*
* @return Illuminate\Database\Query\Builder Modified query builder
*/
@@ -274,23 +274,31 @@ class AssetModel extends SnipeModel
{
return $query->where('models.name', 'LIKE', "%$search%")
->orWhere('model_number', 'LIKE', "%$search%")
- ->orWhere(function ($query) use ($search) {
- $query->whereHas('category', function ($query) use ($search) {
- $query->where('categories.name', 'LIKE', '%'.$search.'%');
- });
- })
- ->orWhere(function ($query) use ($search) {
- $query->whereHas('manufacturer', function ($query) use ($search) {
- $query->where('manufacturers.name', 'LIKE', '%'.$search.'%');
- });
- });
+ ->orWhere(
+ function ($query) use ($search) {
+ $query->whereHas(
+ 'category', function ($query) use ($search) {
+ $query->where('categories.name', 'LIKE', '%'.$search.'%');
+ }
+ );
+ }
+ )
+ ->orWhere(
+ function ($query) use ($search) {
+ $query->whereHas(
+ 'manufacturer', function ($query) use ($search) {
+ $query->where('manufacturers.name', 'LIKE', '%'.$search.'%');
+ }
+ );
+ }
+ );
}
/**
* Query builder scope to order on manufacturer
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -302,8 +310,8 @@ class AssetModel extends SnipeModel
/**
* Query builder scope to order on category name
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -319,7 +327,6 @@ class AssetModel extends SnipeModel
/**
* Query builder scope to order on created_by name
- *
*/
public function scopeOrderByCreatedByName($query, $order)
{
diff --git a/app/Models/Category.php b/app/Models/Category.php
index 08bef4d3eb..7d9d7a14ae 100755
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -18,7 +18,7 @@ use Illuminate\Support\Str;
* to require acceptance from the user, whether or not to
* send a EULA to the user, etc.
*
- * @version v1.0
+ * @version v1.0
*/
class Category extends SnipeModel
{
@@ -96,7 +96,7 @@ class Category extends SnipeModel
* Checks if category can be deleted
*
* @author [Dan Meltzer] [<[email protected]>]
- * @since [v5.0]
+ * @since [v5.0]
* @return bool
*/
public function isDeletable()
@@ -119,7 +119,7 @@ class Category extends SnipeModel
* Establishes the category -> accessories relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function accessories()
@@ -131,7 +131,7 @@ class Category extends SnipeModel
* Establishes the category -> licenses relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.3]
+ * @since [v4.3]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function licenses()
@@ -143,7 +143,7 @@ class Category extends SnipeModel
* Establishes the category -> consumables relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function consumables()
@@ -155,7 +155,7 @@ class Category extends SnipeModel
* Establishes the category -> consumables relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function components()
@@ -170,7 +170,7 @@ class Category extends SnipeModel
* It should only be used in a single category context.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return int
*/
public function itemCount()
@@ -181,18 +181,18 @@ class Category extends SnipeModel
}
switch ($this->category_type) {
- case 'asset':
- return $this->assets->count();
- case 'accessory':
- return $this->accessories->count();
- case 'component':
- return $this->components->count();
- case 'consumable':
- return $this->consumables->count();
- case 'license':
- return $this->licenses->count();
- default:
- return 0;
+ case 'asset':
+ return $this->assets->count();
+ case 'accessory':
+ return $this->accessories->count();
+ case 'component':
+ return $this->components->count();
+ case 'consumable':
+ return $this->consumables->count();
+ case 'license':
+ return $this->licenses->count();
+ default:
+ return 0;
}
}
@@ -201,7 +201,7 @@ class Category extends SnipeModel
* Establishes the category -> assets relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assets()
@@ -218,8 +218,8 @@ class Category extends SnipeModel
* by their category.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v6.1.0]
- * @see \App\Models\Asset::scopeAssetsForShow()
+ * @since [v6.1.0]
+ * @see \App\Models\Asset::scopeAssetsForShow()
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function showableAssets()
@@ -231,7 +231,7 @@ class Category extends SnipeModel
* Establishes the category -> models relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function models()
@@ -249,7 +249,7 @@ class Category extends SnipeModel
* checks for a settings level EULA
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v2.0]
+ * @since [v2.0]
* @return string | null
*/
public function getEula()
@@ -276,7 +276,7 @@ class Category extends SnipeModel
*
* This will also correctly parse a 1/0 if "true"/"false" is passed.
*
- * @param $value
+ * @param $value
* @return void
*/
public function setCheckinEmailAttribute($value)
@@ -293,9 +293,9 @@ class Category extends SnipeModel
/**
* Query builder scope for whether or not the category requires acceptance
*
- * @author Vincent Sposato <[email protected]>
+ * @author Vincent Sposato <[email protected]>
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
public function scopeRequiresAcceptance($query)
diff --git a/app/Models/CheckoutAcceptance.php b/app/Models/CheckoutAcceptance.php
index 2ca9c5b48b..0599286f85 100644
--- a/app/Models/CheckoutAcceptance.php
+++ b/app/Models/CheckoutAcceptance.php
@@ -66,7 +66,7 @@ class CheckoutAcceptance extends Model
/**
* Was the checkoutable checked out to this user?
*
- * @param User $user
+ * @param User $user
* @return bool
*/
public function isCheckedOutTo(User $user)
@@ -79,7 +79,7 @@ class CheckoutAcceptance extends Model
* Do not add stuff here that doesn't have a corresponding column in the
* checkout_acceptances table or you'll get an error.
*
- * @param string $signature_filename
+ * @param string $signature_filename
*/
public function accept($signature_filename, $eula = null, $filename = null, $note = null)
{
@@ -99,7 +99,7 @@ class CheckoutAcceptance extends Model
/**
* Decline the checkout acceptance
*
- * @param string $signature_filename
+ * @param string $signature_filename
*/
public function decline($signature_filename, $note = null)
{
@@ -116,8 +116,9 @@ class CheckoutAcceptance extends Model
/**
* Filter checkout acceptences by the user
+ *
* @param Illuminate\Database\Eloquent\Builder $query
- * @param User $user
+ * @param User $user
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeForUser(Builder $query, User $user)
@@ -127,6 +128,7 @@ class CheckoutAcceptance extends Model
/**
* Filter to only get pending acceptances
+ *
* @param Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
diff --git a/app/Models/Company.php b/app/Models/Company.php
index 9966a32d26..a2f5ddc38b 100644
--- a/app/Models/Company.php
+++ b/app/Models/Company.php
@@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Schema;
/**
* Model for Companies.
*
- * @version v1.8
+ * @version v1.8
*/
final class Company extends SnipeModel
{
@@ -28,19 +28,19 @@ final class Company extends SnipeModel
'name' => 'required|min:1|max:255|unique:companies,name',
'fax' => 'min:7|max:35|nullable',
'phone' => 'min:7|max:35|nullable',
- 'email' => 'email|max:150|nullable',
+ 'email' => 'email|max:150|nullable',
];
protected $presenter = \App\Presenters\CompanyPresenter::class;
use Presentable;
/**
- * Whether the model should inject it's identifier to the unique
- * validation rules before attempting validation. If this property
- * is not set in the model it will default to true.
- *
+ * Whether the model should inject it's identifier to the unique
+ * validation rules before attempting validation. If this property
+ * is not set in the model it will default to true.
+ *
* @var bool
- */
+ */
protected $injectUniqueIdentifier = true;
use ValidatingTrait;
use Searchable;
@@ -102,7 +102,7 @@ final class Company extends SnipeModel
* account the full multiple company support setting
* and if the current user is a super user.
*
- * @param $unescaped_input
+ * @param $unescaped_input
* @return int|mixed|string|null
*/
public static function getIdForCurrentUser($unescaped_input)
@@ -129,7 +129,7 @@ final class Company extends SnipeModel
* Check to see if the current user should have access to the model.
* I hate this method and I think it should be refactored.
*
- * @param $companyable
+ * @param $companyable
* @return bool|void
*/
public static function isCurrentUserHasAccess($companyable)
@@ -192,7 +192,7 @@ final class Company extends SnipeModel
* Checks if company can be deleted
*
* @author [Dan Meltzer] [<[email protected]>]
- * @since [v5.0]
+ * @since [v5.0]
* @return bool
*/
public function isDeletable()
@@ -209,7 +209,7 @@ final class Company extends SnipeModel
}
/**
- * @param $unescaped_input
+ * @param $unescaped_input
* @return int|mixed|string|null
*/
public static function getIdForUser($unescaped_input)
@@ -265,9 +265,9 @@ final class Company extends SnipeModel
* @todo - refactor that trait to handle the user's model as well.
*
* @author [A. Gianotto] <[email protected]>
- * @param $query
- * @param $column
- * @param $table_name
+ * @param $query
+ * @param $column
+ * @param $table_name
* @return mixed
*/
public static function scopeCompanyables($query, $column = 'company_id', $table_name = null)
@@ -327,8 +327,8 @@ final class Company extends SnipeModel
* This gets invoked by CompanyableChildScope, but I'm not sure what it does.
*
* @author [A. Gianotto] <[email protected]>
- * @param array $companyable_names
- * @param $query
+ * @param array $companyable_names
+ * @param $query
* @return mixed
*/
public static function scopeCompanyableChildren(array $companyable_names, $query)
@@ -343,13 +343,15 @@ final class Company extends SnipeModel
static::scopeCompanyablesDirectly($q);
};
- $q = $query->where(function ($q) use ($companyable_names, $f) {
- $q2 = $q->whereHas($companyable_names[0], $f);
+ $q = $query->where(
+ function ($q) use ($companyable_names, $f) {
+ $q2 = $q->whereHas($companyable_names[0], $f);
- for ($i = 1; $i < count($companyable_names); $i++) {
- $q2 = $q2->orWhereHas($companyable_names[$i], $f);
+ for ($i = 1; $i < count($companyable_names); $i++) {
+ $q2 = $q2->orWhereHas($companyable_names[$i], $f);
+ }
}
- });
+ );
return $q;
}
diff --git a/app/Models/CompanyableChildScope.php b/app/Models/CompanyableChildScope.php
index 4077ebd596..35f2049e8b 100644
--- a/app/Models/CompanyableChildScope.php
+++ b/app/Models/CompanyableChildScope.php
@@ -9,15 +9,15 @@ use Illuminate\Database\Eloquent\Scope;
/**
* Handle query scoping for full company support.
*
- * @todo Move this to a more Laravel 5.2 esque way
- * @version v1.0
+ * @todo Move this to a more Laravel 5.2 esque way
+ * @version v1.0
*/
final class CompanyableChildScope implements Scope
{
/**
* Apply the scope to a given Eloquent query builder.
*
- * @param \Illuminate\Database\Eloquent\Builder $builder
+ * @param \Illuminate\Database\Eloquent\Builder $builder
* @return void
*/
public function apply(Builder $builder, Model $model)
@@ -31,7 +31,7 @@ final class CompanyableChildScope implements Scope
* @todo IMPLEMENT
* Remove the scope from the given Eloquent query builder.
*
- * @param \Illuminate\Database\Eloquent\Builder $builder
+ * @param \Illuminate\Database\Eloquent\Builder $builder
* @return void
*/
public function remove(Builder $builder)
diff --git a/app/Models/CompanyableScope.php b/app/Models/CompanyableScope.php
index 4bbe7d6396..bbc0b5e0e6 100644
--- a/app/Models/CompanyableScope.php
+++ b/app/Models/CompanyableScope.php
@@ -9,15 +9,15 @@ use Illuminate\Database\Eloquent\Scope;
/**
* Handle query scoping for full company support.
*
- * @todo Move this to a more Laravel 5.2 esque way
- * @version v1.0
+ * @todo Move this to a more Laravel 5.2 esque way
+ * @version v1.0
*/
final class CompanyableScope implements Scope
{
/**
* Apply the scope to a given Eloquent query builder.
*
- * @param \Illuminate\Database\Eloquent\Builder $builder
+ * @param \Illuminate\Database\Eloquent\Builder $builder
* @return void
*/
public function apply(Builder $builder, Model $model)
@@ -29,7 +29,7 @@ final class CompanyableScope implements Scope
* @todo IMPLEMENT
* Remove the scope from the given Eloquent query builder.
*
- * @param \Illuminate\Database\Eloquent\Builder $builder
+ * @param \Illuminate\Database\Eloquent\Builder $builder
* @return void
*/
public function remove(Builder $builder)
diff --git a/app/Models/CompanyableTrait.php b/app/Models/CompanyableTrait.php
index c4b9b89fbf..183e755086 100644
--- a/app/Models/CompanyableTrait.php
+++ b/app/Models/CompanyableTrait.php
@@ -8,7 +8,7 @@ trait CompanyableTrait
* This trait is used to scope models to the current company. To use this scope on companyable models,
* we use the "use Companyable;" statement at the top of the mode.
*
- * @see \App\Models\Company\Company::scopeCompanyables()
+ * @see \App\Models\Company\Company::scopeCompanyables()
* @return void
*/
public static function bootCompanyableTrait()
diff --git a/app/Models/Component.php b/app/Models/Component.php
index df3289e52f..be362b71bb 100644
--- a/app/Models/Component.php
+++ b/app/Models/Component.php
@@ -13,7 +13,7 @@ use Watson\Validating\ValidatingTrait;
/**
* Model for Components.
*
- * @version v1.0
+ * @version v1.0
*/
class Component extends SnipeModel
{
@@ -121,7 +121,7 @@ class Component extends SnipeModel
* Establishes the component -> location relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function location()
@@ -133,7 +133,7 @@ class Component extends SnipeModel
* Establishes the component -> assets relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assets()
@@ -147,7 +147,7 @@ class Component extends SnipeModel
* @todo this is probably not needed - refactor
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function adminuser()
@@ -159,7 +159,7 @@ class Component extends SnipeModel
* Establishes the component -> company relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function company()
@@ -171,7 +171,7 @@ class Component extends SnipeModel
* Establishes the component -> category relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function category()
@@ -183,7 +183,7 @@ class Component extends SnipeModel
* Establishes the item -> supplier relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v6.1.1]
+ * @since [v6.1.1]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function supplier()
@@ -196,7 +196,7 @@ class Component extends SnipeModel
* Establishes the item -> manufacturer relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function manufacturer()
@@ -208,7 +208,7 @@ class Component extends SnipeModel
* Establishes the component -> action logs relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assetlog()
@@ -220,7 +220,7 @@ class Component extends SnipeModel
* Check how many items within a component are checked out
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v5.0]
+ * @since [v5.0]
* @return int
*/
public function numCheckedOut()
@@ -239,11 +239,12 @@ class Component extends SnipeModel
*
* This allows us to get the assets with assigned components without the company restriction
*/
- public function uncontrainedAssets() {
+ public function uncontrainedAssets()
+ {
return $this->belongsToMany(\App\Models\Asset::class, 'components_assets')
- ->withPivot('id', 'assigned_qty', 'created_at', 'created_by', 'note')
- ->withoutGlobalScope(new CompanyableScope);
+ ->withPivot('id', 'assigned_qty', 'created_at', 'created_by', 'note')
+ ->withoutGlobalScope(new CompanyableScope);
}
@@ -252,7 +253,7 @@ class Component extends SnipeModel
* Check how many items within a component are remaining
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return int
*/
public function numRemaining()
@@ -275,8 +276,8 @@ class Component extends SnipeModel
* This simply checks that there is a value for quantity, and if there isn't, set it to 0.
*
* @author A. Gianotto <[email protected]>
- * @since v6.3.4
- * @param $value
+ * @since v6.3.4
+ * @param $value
* @return void
*/
public function setQtyAttribute($value)
@@ -294,8 +295,8 @@ class Component extends SnipeModel
/**
* Query builder scope to order on company
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -307,8 +308,8 @@ class Component extends SnipeModel
/**
* Query builder scope to order on company
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -320,8 +321,8 @@ class Component extends SnipeModel
/**
* Query builder scope to order on company
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -333,8 +334,8 @@ class Component extends SnipeModel
/**
* Query builder scope to order on supplier
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -346,8 +347,8 @@ class Component extends SnipeModel
/**
* Query builder scope to order on manufacturer
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
diff --git a/app/Models/Consumable.php b/app/Models/Consumable.php
index ba5fa97c2e..f4b6a3ca6b 100644
--- a/app/Models/Consumable.php
+++ b/app/Models/Consumable.php
@@ -125,7 +125,7 @@ class Consumable extends SnipeModel
* @todo Update this comment once it's been implemented
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function setRequestableAttribute($value)
@@ -140,7 +140,7 @@ class Consumable extends SnipeModel
* Establishes the consumable -> admin user relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function adminuser()
@@ -152,7 +152,7 @@ class Consumable extends SnipeModel
* Establishes the component -> assignments relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function consumableAssignments()
@@ -164,7 +164,7 @@ class Consumable extends SnipeModel
* Establishes the component -> company relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function company()
@@ -176,7 +176,7 @@ class Consumable extends SnipeModel
* Establishes the component -> manufacturer relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function manufacturer()
@@ -188,7 +188,7 @@ class Consumable extends SnipeModel
* Establishes the component -> location relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function location()
@@ -200,7 +200,7 @@ class Consumable extends SnipeModel
* Establishes the component -> category relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function category()
@@ -213,7 +213,7 @@ class Consumable extends SnipeModel
* Establishes the component -> action logs relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assetlog()
@@ -225,7 +225,7 @@ class Consumable extends SnipeModel
* Gets the full image url for the consumable
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return string | false
*/
public function getImageUrl()
@@ -241,7 +241,7 @@ class Consumable extends SnipeModel
* Establishes the component -> users relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
*/
public function users() : Relation
{
@@ -252,7 +252,7 @@ class Consumable extends SnipeModel
* Establishes the item -> supplier relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v6.1.1]
+ * @since [v6.1.1]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function supplier()
@@ -266,7 +266,7 @@ class Consumable extends SnipeModel
* asset model category
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return bool
*/
public function checkin_email()
@@ -278,7 +278,7 @@ class Consumable extends SnipeModel
* Determine whether this asset requires acceptance by the assigned user
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return bool
*/
public function requireAcceptance()
@@ -291,7 +291,7 @@ class Consumable extends SnipeModel
* checks for a settings level EULA
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return string | false
*/
public function getEula()
@@ -309,7 +309,7 @@ class Consumable extends SnipeModel
* Check how many items within a consumable are checked out
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v5.0]
+ * @since [v5.0]
* @return int
*/
public function numCheckedOut()
@@ -321,7 +321,7 @@ class Consumable extends SnipeModel
* Checks the number of available consumables
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return int
*/
public function numRemaining()
@@ -347,8 +347,8 @@ class Consumable extends SnipeModel
* This simply checks that there is a value for quantity, and if there isn't, set it to 0.
*
* @author A. Gianotto <[email protected]>
- * @since v6.3.4
- * @param $value
+ * @since v6.3.4
+ * @param $value
* @return void
*/
public function setQtyAttribute($value)
@@ -365,8 +365,8 @@ class Consumable extends SnipeModel
/**
* Query builder scope to order on company
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -378,8 +378,8 @@ class Consumable extends SnipeModel
/**
* Query builder scope to order on location
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -391,8 +391,8 @@ class Consumable extends SnipeModel
/**
* Query builder scope to order on manufacturer
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -404,8 +404,8 @@ class Consumable extends SnipeModel
/**
* Query builder scope to order on company
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -417,8 +417,8 @@ class Consumable extends SnipeModel
/**
* Query builder scope to order on remaining
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -431,8 +431,8 @@ class Consumable extends SnipeModel
/**
* Query builder scope to order on supplier
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
diff --git a/app/Models/CustomField.php b/app/Models/CustomField.php
index b3742882a2..f1865d692f 100644
--- a/app/Models/CustomField.php
+++ b/app/Models/CustomField.php
@@ -92,7 +92,7 @@ class CustomField extends Model
* table instead of the assets table.
*
* @author [Brady Wetherington] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
*/
public static $table_name = 'assets';
@@ -103,7 +103,7 @@ class CustomField extends Model
* do with previously existing values. - @snipe
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.4]
+ * @since [v3.4]
* @return string
*/
public static function name_to_db_name($name)
@@ -120,66 +120,78 @@ class CustomField extends Model
* to do it in the controllers.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.4]
+ * @since [v3.4]
* @return bool
*/
public static function boot()
{
parent::boot();
- self::created(function ($custom_field) {
+ self::created(
+ function ($custom_field) {
- // Column already exists on the assets table - nothing to do here.
- // This *shouldn't* happen in the wild.
- if (Schema::hasColumn(self::$table_name, $custom_field->db_column)) {
- return false;
+ // Column already exists on the assets table - nothing to do here.
+ // This *shouldn't* happen in the wild.
+ if (Schema::hasColumn(self::$table_name, $custom_field->db_column)) {
+ return false;
+ }
+
+ // Update the column name in the assets table
+ Schema::table(
+ self::$table_name, function ($table) use ($custom_field) {
+ $table->text($custom_field->convertUnicodeDbSlug())->nullable();
+ }
+ );
+
+ // Update the db_column property in the custom fields table
+ $custom_field->db_column = $custom_field->convertUnicodeDbSlug();
+ $custom_field->save();
}
+ );
- // Update the column name in the assets table
- Schema::table(self::$table_name, function ($table) use ($custom_field) {
- $table->text($custom_field->convertUnicodeDbSlug())->nullable();
- });
+ self::updating(
+ function ($custom_field) {
- // Update the db_column property in the custom fields table
- $custom_field->db_column = $custom_field->convertUnicodeDbSlug();
- $custom_field->save();
- });
+ // Column already exists on the assets table - nothing to do here.
+ if ($custom_field->isDirty('name')) {
+ if (Schema::hasColumn(self::$table_name, $custom_field->convertUnicodeDbSlug())) {
+ return true;
+ }
- self::updating(function ($custom_field) {
+ // Rename the field if the name has changed
+ Schema::table(
+ self::$table_name, function ($table) use ($custom_field) {
+ $table->renameColumn($custom_field->convertUnicodeDbSlug($custom_field->getOriginal('name')), $custom_field->convertUnicodeDbSlug());
+ }
+ );
+
+ // Save the updated column name to the custom fields table
+ $custom_field->db_column = $custom_field->convertUnicodeDbSlug();
+ $custom_field->save();
- // Column already exists on the assets table - nothing to do here.
- if ($custom_field->isDirty('name')) {
- if (Schema::hasColumn(self::$table_name, $custom_field->convertUnicodeDbSlug())) {
return true;
}
- // Rename the field if the name has changed
- Schema::table(self::$table_name, function ($table) use ($custom_field) {
- $table->renameColumn($custom_field->convertUnicodeDbSlug($custom_field->getOriginal('name')), $custom_field->convertUnicodeDbSlug());
- });
-
- // Save the updated column name to the custom fields table
- $custom_field->db_column = $custom_field->convertUnicodeDbSlug();
- $custom_field->save();
-
return true;
}
-
- return true;
- });
+ );
// Drop the assets column if we've deleted it from custom fields
- self::deleting(function ($custom_field) {
- return Schema::table(self::$table_name, function ($table) use ($custom_field) {
- $table->dropColumn($custom_field->db_column);
- });
- });
+ self::deleting(
+ function ($custom_field) {
+ return Schema::table(
+ self::$table_name, function ($table) use ($custom_field) {
+ $table->dropColumn($custom_field->db_column);
+ }
+ );
+ }
+ );
}
/**
* Establishes the customfield -> fieldset relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function fieldset()
@@ -214,26 +226,26 @@ class CustomField extends Model
public function displayFieldInCurrentForm($form_type = null)
{
switch ($form_type) {
- case 'audit':
- return $this->displayFieldInAuditForm();
- case 'checkin':
- return $this->displayFieldInCheckinForm();
- case 'checkout':
- return $this->displayFieldInCheckoutForm();
+ case 'audit':
+ return $this->displayFieldInAuditForm();
+ case 'checkin':
+ return $this->displayFieldInCheckinForm();
+ case 'checkout':
+ return $this->displayFieldInCheckoutForm();
}
}
public function assetModels()
{
- return $this->fieldset()->with('models')->get()->pluck('models')->flatten()->unique('id');
+ return $this->fieldset()->with('models')->get()->pluck('models')->flatten()->unique('id');
}
/**
* Establishes the customfield -> admin user relationship
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function user()
@@ -245,7 +257,7 @@ class CustomField extends Model
* Establishes the customfield -> default values relationship
*
* @author Hannah Tinkler
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function defaultValues()
@@ -262,19 +274,23 @@ class CustomField extends Model
*/
public function defaultValue($modelId)
{
- return $this->defaultValues->filter(function ($item) use ($modelId) {
- return $item->pivot->asset_model_id == $modelId;
- })->map(function ($item) {
- return $item->pivot->default_value;
- })->first();
+ return $this->defaultValues->filter(
+ function ($item) use ($modelId) {
+ return $item->pivot->asset_model_id == $modelId;
+ }
+ )->map(
+ function ($item) {
+ return $item->pivot->default_value;
+ }
+ )->first();
}
/**
* Checks the format of the attribute
*
* @author [A. Gianotto] [<[email protected]>]
- * @param $value string
- * @since [v3.0]
+ * @param $value string
+ * @since [v3.0]
* @return bool
*/
public function check_format($value)
@@ -286,7 +302,7 @@ class CustomField extends Model
* Gets the DB column name.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return string
*/
public function db_column_name()
@@ -302,7 +318,7 @@ class CustomField extends Model
* user-friendly text in the dropdowns, and in the custom fields display.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.4]
+ * @since [v3.4]
* @return string
*/
public function getFormatAttribute($value)
@@ -320,7 +336,7 @@ class CustomField extends Model
* Format a value string as an array for select boxes and checkboxes.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.4]
+ * @since [v3.4]
* @return array
*/
public function setFormatAttribute($value)
@@ -336,7 +352,7 @@ class CustomField extends Model
* Format a value string as an array for select boxes and checkboxes.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.4]
+ * @since [v3.4]
* @return array
*/
public function formatFieldValuesAsArray()
@@ -366,7 +382,7 @@ class CustomField extends Model
* Check whether the field is encrypted
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.4]
+ * @since [v3.4]
* @return bool
*/
public function isFieldDecryptable($string)
@@ -383,7 +399,7 @@ class CustomField extends Model
* won't break the database.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.4]
+ * @since [v3.4]
* @return string
*/
public function convertUnicodeDbSlug($original = null)
@@ -392,7 +408,7 @@ class CustomField extends Model
$id = $this->id ? $this->id : 'xx';
if (! function_exists('transliterator_transliterate')) {
- $long_slug = '_snipeit_'.str_slug(mb_convert_encoding(trim($name),"UTF-8"), '_');
+ $long_slug = '_snipeit_'.str_slug(mb_convert_encoding(trim($name), "UTF-8"), '_');
} else {
$long_slug = '_snipeit_'.Utf8Slugger::slugify($name, '_');
}
@@ -402,9 +418,10 @@ class CustomField extends Model
/**
* Get validation rules for custom fields to use with Validator
+ *
* @author [V. Cordes] [<[email protected]>]
- * @param int $id
- * @since [v4.1.10]
+ * @param int $id
+ * @since [v4.1.10]
* @return array
*/
public function validationRules($regex_format = null)
@@ -418,6 +435,7 @@ class CustomField extends Model
/**
* Check to see if there is a custom regex format type
+ *
* @see https://github.com/grokability/snipe-it/issues/5896
*
* @author Wes Hulette <[email protected]>
diff --git a/app/Models/CustomFieldset.php b/app/Models/CustomFieldset.php
index e5490b49b3..7c9ad7dd81 100644
--- a/app/Models/CustomFieldset.php
+++ b/app/Models/CustomFieldset.php
@@ -20,6 +20,7 @@ class CustomFieldset extends Model
/**
* Validation rules
+ *
* @var array
*/
public $rules = [
@@ -39,7 +40,7 @@ class CustomFieldset extends Model
* Establishes the fieldset -> field relationship
*
* @author [Brady Wetherington] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function fields()
@@ -51,7 +52,7 @@ class CustomFieldset extends Model
* Establishes the fieldset -> models relationship
*
* @author [Brady Wetherington] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function models()
@@ -63,7 +64,7 @@ class CustomFieldset extends Model
* Establishes the fieldset -> admin user relationship
*
* @author [Brady Wetherington] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function user()
@@ -76,14 +77,14 @@ class CustomFieldset extends Model
if ($this->fields) {
switch ($form_type) {
- case 'audit':
- return $this->fields->where('display_audit', '1')->count() > 0;
- case 'checkin':
- return $this->fields->where('display_checkin', '1')->count() > 0;
- case 'checkout':
- return $this->fields->where('display_checkout', '1')->count() > 0;
- default:
- return true;
+ case 'audit':
+ return $this->fields->where('display_audit', '1')->count() > 0;
+ case 'checkin':
+ return $this->fields->where('display_checkin', '1')->count() > 0;
+ case 'checkout':
+ return $this->fields->where('display_checkout', '1')->count() > 0;
+ default:
+ return true;
}
}
@@ -95,7 +96,7 @@ class CustomFieldset extends Model
* custom field format
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return array
*/
public function validation_rules()
@@ -104,8 +105,9 @@ class CustomFieldset extends Model
foreach ($this->fields as $field) {
$rule = [];
- if (($field->field_encrypted != '1') ||
- (($field->field_encrypted == '1') && (Gate::allows('admin')))) {
+ if (($field->field_encrypted != '1')
+ || (($field->field_encrypted == '1') && (Gate::allows('admin')))
+ ) {
$rule[] = ($field->pivot->required == '1') ? 'required' : 'nullable';
}
diff --git a/app/Models/Department.php b/app/Models/Department.php
index 592fd840b1..79616101e3 100644
--- a/app/Models/Department.php
+++ b/app/Models/Department.php
@@ -72,7 +72,7 @@ class Department extends SnipeModel
* Establishes the department -> company relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function company()
@@ -84,7 +84,7 @@ class Department extends SnipeModel
* Establishes the department -> users relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function users()
@@ -96,7 +96,7 @@ class Department extends SnipeModel
* Establishes the department -> manager relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function manager()
@@ -108,7 +108,7 @@ class Department extends SnipeModel
* Establishes the department -> location relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function location()
@@ -119,8 +119,8 @@ class Department extends SnipeModel
/**
* Query builder scope to order on location name
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -132,8 +132,8 @@ class Department extends SnipeModel
/**
* Query builder scope to order on manager name
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -145,8 +145,8 @@ class Department extends SnipeModel
/**
* Query builder scope to order on company
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
diff --git a/app/Models/Depreciable.php b/app/Models/Depreciable.php
index 0c513a3d33..b4cd40e1d1 100644
--- a/app/Models/Depreciable.php
+++ b/app/Models/Depreciable.php
@@ -48,15 +48,15 @@ class Depreciable extends SnipeModel
$depreciation = 0;
$setting = Setting::getSettings();
switch ($setting->depreciation_method) {
- case 'half_1':
+ case 'half_1':
$depreciation = $this->getHalfYearDepreciatedValue(true);
break;
- case 'half_2':
+ case 'half_2':
$depreciation = $this->getHalfYearDepreciatedValue(false);
break;
- default:
+ default:
$depreciation = $this->getLinearDepreciatedValue();
}
@@ -74,7 +74,7 @@ class Depreciable extends SnipeModel
return null;
}
- if ($months_passed >= $this->get_depreciation()->months){
+ if ($months_passed >= $this->get_depreciation()->months) {
//if there is a floor use it
if($this->get_depreciation()->depreciation_min) {
@@ -93,14 +93,15 @@ class Depreciable extends SnipeModel
return $current_value;
}
- public function getMonthlyDepreciation(){
+ public function getMonthlyDepreciation()
+ {
return ($this->purchase_cost-$this->calculateDepreciation())/$this->get_depreciation()->months;
}
/**
- * @param onlyHalfFirstYear Boolean always applied only second half of the first year
+ * @param onlyHalfFirstYear Boolean always applied only second half of the first year
* @return float|int
*/
public function getHalfYearDepreciatedValue($onlyHalfFirstYear = false)
@@ -131,7 +132,7 @@ class Depreciable extends SnipeModel
}
/**
- * @param \DateTime $date
+ * @param \DateTime $date
* @return int
*/
protected function get_fiscal_year($date)
@@ -146,7 +147,7 @@ class Depreciable extends SnipeModel
}
/**
- * @param \DateTime $date
+ * @param \DateTime $date
* @return bool
*/
protected function is_first_half_of_year($date)
diff --git a/app/Models/Depreciation.php b/app/Models/Depreciation.php
index f6ed78649a..6e01c6d782 100755
--- a/app/Models/Depreciation.php
+++ b/app/Models/Depreciation.php
@@ -56,7 +56,7 @@ class Depreciation extends SnipeModel
* Establishes the depreciation -> models relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v5.0]
+ * @since [v5.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function models()
@@ -68,7 +68,7 @@ class Depreciation extends SnipeModel
* Establishes the depreciation -> licenses relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v5.0]
+ * @since [v5.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function licenses()
@@ -80,7 +80,7 @@ class Depreciation extends SnipeModel
* Establishes the depreciation -> assets relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v5.0]
+ * @since [v5.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assets()
@@ -92,7 +92,7 @@ class Depreciation extends SnipeModel
* Get the user that created the depreciation
*
* @author A. Gianotto <[email protected]>
- * @since [v7.0.13]
+ * @since [v7.0.13]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function adminuser()
diff --git a/app/Models/Group.php b/app/Models/Group.php
index 6dae273998..9f4f2e2e56 100755
--- a/app/Models/Group.php
+++ b/app/Models/Group.php
@@ -51,7 +51,7 @@ class Group extends SnipeModel
* Establishes the groups -> users relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function users()
@@ -63,7 +63,7 @@ class Group extends SnipeModel
* Get the user that created the group
*
* @author A. Gianotto <[email protected]>
- * @since [v6.3.0]
+ * @since [v6.3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function adminuser()
@@ -75,7 +75,7 @@ class Group extends SnipeModel
* Decode JSON permissions into array
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return array | \stdClass
*/
public function decodePermissions()
diff --git a/app/Models/Import.php b/app/Models/Import.php
index d824a3840c..4ea259ba05 100644
--- a/app/Models/Import.php
+++ b/app/Models/Import.php
@@ -19,7 +19,7 @@ class Import extends Model
* Establishes the license -> admin user relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function adminuser()
diff --git a/app/Models/Labels/DefaultLabel.php b/app/Models/Labels/DefaultLabel.php
index f869110138..fa60dafab3 100644
--- a/app/Models/Labels/DefaultLabel.php
+++ b/app/Models/Labels/DefaultLabel.php
@@ -38,7 +38,8 @@ class DefaultLabel extends RectangleSheet
private int $rows;
- public function __construct() {
+ public function __construct()
+ {
$settings = Setting::getSettings();
$this->textSize = Helper::convertUnit($settings->labels_fontsize, 'pt', 'in');
@@ -74,41 +75,116 @@ class DefaultLabel extends RectangleSheet
}
- public function getUnit() { return 'in'; }
+ public function getUnit()
+ {
+ return 'in';
+ }
- public function getPageWidth() { return $this->pageWidth; }
- public function getPageHeight() { return $this->pageHeight; }
+ public function getPageWidth()
+ {
+ return $this->pageWidth;
+ }
+ public function getPageHeight()
+ {
+ return $this->pageHeight;
+ }
- public function getPageMarginTop() { return $this->pageMarginTop; }
- public function getPageMarginBottom() { return $this->pageMarginBottom; }
- public function getPageMarginLeft() { return $this->pageMarginLeft; }
- public function getPageMarginRight() { return $this->pageMarginRight; }
+ public function getPageMarginTop()
+ {
+ return $this->pageMarginTop;
+ }
+ public function getPageMarginBottom()
+ {
+ return $this->pageMarginBottom;
+ }
+ public function getPageMarginLeft()
+ {
+ return $this->pageMarginLeft;
+ }
+ public function getPageMarginRight()
+ {
+ return $this->pageMarginRight;
+ }
- public function getColumns() { return $this->columns; }
- public function getRows() { return $this->rows; }
- public function getLabelBorder() { return 0; }
+ public function getColumns()
+ {
+ return $this->columns;
+ }
+ public function getRows()
+ {
+ return $this->rows;
+ }
+ public function getLabelBorder()
+ {
+ return 0;
+ }
- public function getLabelWidth() { return $this->labelWidth; }
- public function getLabelHeight() { return $this->labelHeight; }
+ public function getLabelWidth()
+ {
+ return $this->labelWidth;
+ }
+ public function getLabelHeight()
+ {
+ return $this->labelHeight;
+ }
- public function getLabelMarginTop() { return 0; }
- public function getLabelMarginBottom() { return 0; }
- public function getLabelMarginLeft() { return 0; }
- public function getLabelMarginRight() { return 0; }
+ public function getLabelMarginTop()
+ {
+ return 0;
+ }
+ public function getLabelMarginBottom()
+ {
+ return 0;
+ }
+ public function getLabelMarginLeft()
+ {
+ return 0;
+ }
+ public function getLabelMarginRight()
+ {
+ return 0;
+ }
- public function getLabelColumnSpacing() { return $this->labelSpacingH; }
- public function getLabelRowSpacing() { return $this->labelSpacingV; }
+ public function getLabelColumnSpacing()
+ {
+ return $this->labelSpacingH;
+ }
+ public function getLabelRowSpacing()
+ {
+ return $this->labelSpacingV;
+ }
- public function getSupportAssetTag() { return false; }
- public function getSupport1DBarcode() { return true; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 4; }
- public function getSupportTitle() { return true; }
- public function getSupportLogo() { return true; }
+ public function getSupportAssetTag()
+ {
+ return false;
+ }
+ public function getSupport1DBarcode()
+ {
+ return true;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 4;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
+ public function getSupportLogo()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$asset = $record->get('asset');
$settings = Setting::getSettings();
diff --git a/app/Models/Labels/Field.php b/app/Models/Labels/Field.php
index c023f54175..cdd40cac49 100644
--- a/app/Models/Labels/Field.php
+++ b/app/Models/Labels/Field.php
@@ -5,21 +5,30 @@ namespace App\Models\Labels;
use App\Models\Asset;
use Illuminate\Support\Collection;
-class Field {
+class Field
+{
protected Collection $options;
- public function getOptions() { return $this->options; }
- public function setOptions($options) {
+ public function getOptions()
+ {
+ return $this->options;
+ }
+ public function setOptions($options)
+ {
$tempCollect = collect($options);
if (!$tempCollect->contains(fn($o) => !is_subclass_of($o, FieldOption::class))) {
$this->options = $options;
}
}
- public function toArray(Asset $asset) { return Field::makeArray($this, $asset); }
+ public function toArray(Asset $asset)
+ {
+ return Field::makeArray($this, $asset);
+ }
/* Statics */
- public static function makeArray(Field $field, Asset $asset) {
+ public static function makeArray(Field $field, Asset $asset)
+ {
return $field->getOptions()
// filter out any FieldOptions that are accidentally null
->filter()
@@ -27,11 +36,13 @@ class Field {
->filter(fn($result) => $result['value'] != null);
}
- public static function makeString(Field $option) {
+ public static function makeString(Field $option)
+ {
return implode('|', $option->getOptions());
}
- public static function fromString(string $theString) {
+ public static function fromString(string $theString)
+ {
$field = new Field();
$field->options = collect(explode('|', $theString))
->filter(fn($optionString) => !empty($optionString))
diff --git a/app/Models/Labels/FieldOption.php b/app/Models/Labels/FieldOption.php
index 94394eda23..916707b21d 100644
--- a/app/Models/Labels/FieldOption.php
+++ b/app/Models/Labels/FieldOption.php
@@ -5,14 +5,22 @@ namespace App\Models\Labels;
use App\Models\Asset;
use Illuminate\Support\Collection;
-class FieldOption {
+class FieldOption
+{
protected string $label;
- public function getLabel() { return $this->label; }
+ public function getLabel()
+ {
+ return $this->label;
+ }
protected string $dataSource;
- public function getDataSource() { return $this->dataSource; }
+ public function getDataSource()
+ {
+ return $this->dataSource;
+ }
- public function getValue(Asset $asset) {
+ public function getValue(Asset $asset)
+ {
$dataPath = collect(explode('.', $this->dataSource));
// assignedTo directly on the asset is a special case where
@@ -33,18 +41,29 @@ class FieldOption {
return $asset->purchase_date ? $asset->purchase_date->format('Y-m-d') : null;
}
- return $dataPath->reduce(function ($myValue, $path) {
- try { return $myValue ? $myValue->{$path} : ${$myValue}; }
- catch (\Exception $e) { return $myValue; }
- }, $asset);
+ return $dataPath->reduce(
+ function ($myValue, $path) {
+ try { return $myValue ? $myValue->{$path} : ${$myValue};
+ }
+ catch (\Exception $e) { return $myValue;
+ }
+ }, $asset
+ );
}
- public function toArray(Asset $asset=null) { return FieldOption::makeArray($this, $asset); }
- public function toString() { return FieldOption::makeString($this); }
+ public function toArray(Asset $asset=null)
+ {
+ return FieldOption::makeArray($this, $asset);
+ }
+ public function toString()
+ {
+ return FieldOption::makeString($this);
+ }
/* Statics */
- public static function makeArray(FieldOption $option, Asset $asset=null) {
+ public static function makeArray(FieldOption $option, Asset $asset=null)
+ {
return [
'label' => $option->getLabel(),
'dataSource' => $option->getDataSource(),
@@ -52,11 +71,13 @@ class FieldOption {
];
}
- public static function makeString(FieldOption $option) {
+ public static function makeString(FieldOption $option)
+ {
return $option->getLabel() . '=' . $option->getDataSource();
}
- public static function fromString(string $theString) {
+ public static function fromString(string $theString)
+ {
$parts = explode('=', $theString);
if (count($parts) == 2) {
$option = new FieldOption();
diff --git a/app/Models/Labels/Label.php b/app/Models/Labels/Label.php
index 2405da5401..cff859f359 100644
--- a/app/Models/Labels/Label.php
+++ b/app/Models/Labels/Label.php
@@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Log;
/**
* Model for Labels.
*
- * @version v1.0
+ * @version v1.0
*/
abstract class Label
{
@@ -32,7 +32,8 @@ abstract class Label
*
* @return int
*/
- public function getRotation() {
+ public function getRotation()
+ {
return 0;
}
@@ -123,29 +124,32 @@ abstract class Label
/**
* Make changes to the PDF properties here. OPTIONAL.
*
- * @param TCPDF $pdf The TCPDF instance
+ * @param TCPDF $pdf The TCPDF instance
*/
public abstract function preparePDF(TCPDF $pdf);
/**
* Write single data record as content here.
*
- * @param TCPDF $pdf The TCPDF instance
- * @param Collection $record A data record
+ * @param TCPDF $pdf The TCPDF instance
+ * @param Collection $record A data record
*/
public abstract function write(TCPDF $pdf, Collection $record);
/**
* Handle the data here. Override for multiple-per-page handling
*
- * @param TCPDF $pdf The TCPDF instance
- * @param Collection $data The data
+ * @param TCPDF $pdf The TCPDF instance
+ * @param Collection $data The data
*/
- public function writeAll(TCPDF $pdf, Collection $data) {
- $data->each(function ($record, $index) use ($pdf) {
- $pdf->AddPage();
- $this->write($pdf, $record);
- });
+ public function writeAll(TCPDF $pdf, Collection $data)
+ {
+ $data->each(
+ function ($record, $index) use ($pdf) {
+ $pdf->AddPage();
+ $this->write($pdf, $record);
+ }
+ );
}
/**
@@ -153,7 +157,8 @@ abstract class Label
*
* @return string
*/
- public final function getName() {
+ public final function getName()
+ {
$refClass = new \ReflectionClass(Label::class);
return str_replace($refClass->getNamespaceName() . '\\', '', get_class($this));
}
@@ -165,7 +170,8 @@ abstract class Label
*
* @return string
*/
- public final function getOrientation() {
+ public final function getOrientation()
+ {
return ($this->getWidth() >= $this->getHeight()) ? 'L' : 'P';
}
@@ -174,7 +180,8 @@ abstract class Label
*
* @return object [ 'x1'=>0.00, 'y1'=>0.00, 'x2'=>0.00, 'y2'=>0.00, 'w'=>0.00, 'h'=>0.00 ]
*/
- public final function getPrintableArea() {
+ public final function getPrintableArea()
+ {
return (object)[
'x1' => $this->getMarginLeft(),
'y1' => $this->getMarginTop(),
@@ -188,21 +195,22 @@ abstract class Label
/**
* Write a text cell.
*
- * @param TCPDF $pdf The TCPDF instance
- * @param string $text The text to write. Supports 'some **bold** text'.
- * @param float $x X position of top-left
- * @param float $y Y position of top-left
- * @param string $font The font family
- * @param string $style The font style
- * @param int $size The font size in getUnit() units
- * @param string $align Align text in the box. 'L' left, 'R' right, 'C' center.
- * @param float $width Force text box width. NULL to auto-fit.
- * @param float $height Force text box height. NULL to auto-fit.
- * @param bool $squash Squash text if it's too big
- * @param int $border Thickness of border. Default = 0.
- * @param int $spacing Letter spacing. Default = 0.
+ * @param TCPDF $pdf The TCPDF instance
+ * @param string $text The text to write. Supports 'some **bold** text'.
+ * @param float $x X position of top-left
+ * @param float $y Y position of top-left
+ * @param string $font The font family
+ * @param string $style The font style
+ * @param int $size The font size in getUnit() units
+ * @param string $align Align text in the box. 'L' left, 'R' right, 'C' center.
+ * @param float $width Force text box width. NULL to auto-fit.
+ * @param float $height Force text box height. NULL to auto-fit.
+ * @param bool $squash Squash text if it's too big
+ * @param int $border Thickness of border. Default = 0.
+ * @param int $spacing Letter spacing. Default = 0.
*/
- public final function writeText(TCPDF $pdf, $text, $x, $y, $font=null, $style=null, $size=null, $align='L', $width=null, $height=null, $squash=false, $border=0, $spacing=0) {
+ public final function writeText(TCPDF $pdf, $text, $x, $y, $font=null, $style=null, $size=null, $align='L', $width=null, $height=null, $squash=false, $border=0, $spacing=0)
+ {
$prevFamily = $pdf->getFontFamily();
$prevStyle = $pdf->getFontStyle();
$prevSizePt = $pdf->getFontSizePt();
@@ -211,33 +219,42 @@ abstract class Label
$fontFamily = !empty($font) ? $font : $prevFamily;
$fontStyle = !empty($style) ? $style : $prevStyle;
- if ($size) $fontSizePt = Helper::convertUnit($size, $this->getUnit(), 'pt', true);
- else $fontSizePt = $prevSizePt;
+ if ($size) { $fontSizePt = Helper::convertUnit($size, $this->getUnit(), 'pt', true);
+ } else { $fontSizePt = $prevSizePt;
+ }
$pdf->SetFontSpacing($spacing);
$parts = collect(explode('**', $text))
- ->map(function ($part, $index) use ($pdf, $fontFamily, $fontStyle, $fontSizePt) {
- $modStyle = ($index % 2 == 1) ? 'B' : $fontStyle;
- $pdf->setFont($fontFamily, $modStyle, $fontSizePt);
- return [
+ ->map(
+ function ($part, $index) use ($pdf, $fontFamily, $fontStyle, $fontSizePt) {
+ $modStyle = ($index % 2 == 1) ? 'B' : $fontStyle;
+ $pdf->setFont($fontFamily, $modStyle, $fontSizePt);
+ return [
'text' => $part,
'text_width' => $pdf->GetStringWidth($part),
'font_family' => $fontFamily,
'font_style' => $modStyle,
'font_size' => $fontSizePt,
- ];
- });
+ ];
+ }
+ );
- $textWidth = $parts->reduce(function ($carry, $part) { return $carry += $part['text_width']; });
+ $textWidth = $parts->reduce(
+ function ($carry, $part) {
+ return $carry += $part['text_width'];
+ }
+ );
$cellWidth = !empty($width) ? $width : $textWidth;
if ($squash && ($textWidth > 0)) {
$scaleFactor = min(1.0, $cellWidth / $textWidth);
- $parts = $parts->map(function ($part, $index) use ($scaleFactor) {
- $part['text_width'] = $part['text_width'] * $scaleFactor;
- return $part;
- });
+ $parts = $parts->map(
+ function ($part, $index) use ($scaleFactor) {
+ $part['text_width'] = $part['text_width'] * $scaleFactor;
+ return $part;
+ }
+ );
}
$cellHeight = !empty($height) ? $height : Helper::convertUnit($fontSizePt, 'pt', $this->getUnit());
@@ -249,18 +266,23 @@ abstract class Label
}
switch($align) {
- case 'R': $startX = ($x + $cellWidth) - min($cellWidth, $textWidth); break;
- case 'C': $startX = ($x + ($cellWidth / 2)) - (min($cellWidth, $textWidth) / 2); break;
- case 'L':
- default: $startX = $x; break;
+ case 'R': $startX = ($x + $cellWidth) - min($cellWidth, $textWidth);
+ break;
+ case 'C': $startX = ($x + ($cellWidth / 2)) - (min($cellWidth, $textWidth) / 2);
+ break;
+ case 'L':
+ default: $startX = $x;
+ break;
}
- $parts->reduce(function ($currentX, $part) use ($pdf, $y, $cellHeight) {
- $pdf->SetXY($currentX, $y);
- $pdf->setFont($part['font_family'], $part['font_style'], $part['font_size']);
- $pdf->Cell($part['text_width'], $cellHeight, $part['text'], 0, 0, '', false, '', 1, true);
- return $currentX += $part['text_width'];
- }, $startX);
+ $parts->reduce(
+ function ($currentX, $part) use ($pdf, $y, $cellHeight) {
+ $pdf->SetXY($currentX, $y);
+ $pdf->setFont($part['font_family'], $part['font_style'], $part['font_size']);
+ $pdf->Cell($part['text_width'], $cellHeight, $part['text'], 0, 0, '', false, '', 1, true);
+ return $currentX += $part['text_width'];
+ }, $startX
+ );
$pdf->SetFont($prevFamily, $prevStyle, $prevSizePt);
$pdf->SetFontSpacing(0);
@@ -269,27 +291,30 @@ abstract class Label
/**
* Write an image.
*
- * @param TCPDF $pdf The TCPDF instance
- * @param string $image The image to write
- * @param float $x X position of top-left
- * @param float $y Y position of top-left
- * @param float $width The container width
- * @param float $height The container height
- * @param string $halign Align text in the box. 'L' left, 'R' right, 'C' center. Default 'L'.
- * @param string $valign Align text in the box. 'T' top, 'B' bottom, 'C' center. Default 'T'.
- * @param int $dpi Pixels per inch
- * @param bool $resize Resize to fit container
- * @param bool $stretch Stretch (vs Scale) to fit container
- * @param int $border Thickness of border. Default = 0.
+ * @param TCPDF $pdf The TCPDF instance
+ * @param string $image The image to write
+ * @param float $x X position of top-left
+ * @param float $y Y position of top-left
+ * @param float $width The container width
+ * @param float $height The container height
+ * @param string $halign Align text in the box. 'L' left, 'R' right, 'C' center. Default 'L'.
+ * @param string $valign Align text in the box. 'T' top, 'B' bottom, 'C' center. Default 'T'.
+ * @param int $dpi Pixels per inch
+ * @param bool $resize Resize to fit container
+ * @param bool $stretch Stretch (vs Scale) to fit container
+ * @param int $border Thickness of border. Default = 0.
*
* @return array Returns the final calculated size [w,h]
*/
- public final function writeImage(TCPDF $pdf, $image, $x, $y, $width=null, $height=null, $halign='L', $valign='L', $dpi=300, $resize=false, $stretch=false, $border=0) {
+ public final function writeImage(TCPDF $pdf, $image, $x, $y, $width=null, $height=null, $halign='L', $valign='L', $dpi=300, $resize=false, $stretch=false, $border=0)
+ {
- if (empty($image)) return [0,0];
+ if (empty($image)) { return [0,0];
+ }
$imageInfo = getimagesize($image);
- if (!$imageInfo) return [0,0]; // TODO: SVG or other
+ if (!$imageInfo) { return [0,0]; // TODO: SVG or other
+ }
$imageWidthPx = $imageInfo[0];
$imageHeightPx = $imageInfo[1];
@@ -342,18 +367,24 @@ abstract class Label
// Horizontal Position
switch ($halign) {
- case 'R': $originX = ($x + $containerWidth) - $outputWidth; break;
- case 'C': $originX = ($x + ($containerWidth / 2)) - ($outputWidth / 2); break;
- case 'L':
- default: $originX = $x; break;
+ case 'R': $originX = ($x + $containerWidth) - $outputWidth;
+ break;
+ case 'C': $originX = ($x + ($containerWidth / 2)) - ($outputWidth / 2);
+ break;
+ case 'L':
+ default: $originX = $x;
+ break;
}
// Vertical Position
switch ($valign) {
- case 'B': $originY = ($y + $containerHeight) - $outputHeight; break;
- case 'C': $originY = ($y + ($containerHeight / 2)) - ($outputHeight / 2); break;
- case 'T':
- default: $originY = $y; break;
+ case 'B': $originY = ($y + $containerHeight) - $outputHeight;
+ break;
+ case 'C': $originY = ($y + ($containerHeight / 2)) - ($outputHeight / 2);
+ break;
+ case 'T':
+ default: $originY = $y;
+ break;
}
// Actual Image
@@ -373,16 +404,18 @@ abstract class Label
/**
* Write a 1D barcode.
*
- * @param TCPDF $pdf The TCPDF instance
- * @param string $value The barcode content
- * @param string $type The barcode type
- * @param float $x X position of top-left
- * @param float $y Y position of top-left
- * @param float $width The container width
- * @param float $height The container height
+ * @param TCPDF $pdf The TCPDF instance
+ * @param string $value The barcode content
+ * @param string $type The barcode type
+ * @param float $x X position of top-left
+ * @param float $y Y position of top-left
+ * @param float $width The container width
+ * @param float $height The container height
*/
- public final function write1DBarcode(TCPDF $pdf, $value, $type, $x, $y, $width, $height) {
- if (empty($value)) return;
+ public final function write1DBarcode(TCPDF $pdf, $value, $type, $x, $y, $width, $height)
+ {
+ if (empty($value)) { return;
+ }
try {
$pdf->write1DBarcode($value, $type, $x, $y, $width, $height, null, ['stretch'=>true]);
} catch (\Exception|TypeError $e) {
@@ -393,16 +426,18 @@ abstract class Label
/**
* Write a 2D barcode.
*
- * @param TCPDF $pdf The TCPDF instance
- * @param string $value The barcode content
- * @param string $type The barcode type
- * @param float $x X position of top-left
- * @param float $y Y position of top-left
- * @param float $width The container width
- * @param float $height The container height
+ * @param TCPDF $pdf The TCPDF instance
+ * @param string $value The barcode content
+ * @param string $type The barcode type
+ * @param float $x X position of top-left
+ * @param float $y Y position of top-left
+ * @param float $width The container width
+ * @param float $height The container height
*/
- public final function write2DBarcode(TCPDF $pdf, $value, $type, $x, $y, $width, $height) {
- if (empty($value)) return;
+ public final function write2DBarcode(TCPDF $pdf, $value, $type, $x, $y, $width, $height)
+ {
+ if (empty($value)) { return;
+ }
$pdf->write2DBarcode($value, $type, $x, $y, $width, $height, null, ['stretch'=>true]);
}
@@ -411,127 +446,180 @@ abstract class Label
/**
* Checks the template is internally valid
*/
- public final function validate() : void {
+ public final function validate() : void
+ {
$this->validateUnits();
$this->validateSize();
$this->validateMargins();
$this->validateSupport();
}
- private function validateUnits() : void {
+ private function validateUnits() : void
+ {
$validUnits = [ 'pt', 'mm', 'cm', 'in' ];
$unit = $this->getUnit();
if (!in_array(strtolower($unit), $validUnits)) {
- throw new \UnexpectedValueException(trans('admin/labels/message.invalid_return_value', [
- 'name' => 'getUnit()',
- 'expected' => '[ \''.implode('\', \'', $validUnits).'\' ]',
- 'actual' => '\''.$unit.'\''
- ]));
+ throw new \UnexpectedValueException(
+ trans(
+ 'admin/labels/message.invalid_return_value', [
+ 'name' => 'getUnit()',
+ 'expected' => '[ \''.implode('\', \'', $validUnits).'\' ]',
+ 'actual' => '\''.$unit.'\''
+ ]
+ )
+ );
}
}
- private function validateSize() : void {
+ private function validateSize() : void
+ {
$width = $this->getWidth();
if (!is_numeric($width) || is_string($width)) {
- throw new \UnexpectedValueException(trans('admin/labels/message.invalid_return_type', [
- 'name' => 'getWidth()',
- 'expected' => 'float',
- 'actual' => gettype($width)
- ]));
+ throw new \UnexpectedValueException(
+ trans(
+ 'admin/labels/message.invalid_return_type', [
+ 'name' => 'getWidth()',
+ 'expected' => 'float',
+ 'actual' => gettype($width)
+ ]
+ )
+ );
}
$height = $this->getHeight();
if (!is_numeric($height) || is_string($height)) {
- throw new \UnexpectedValueException(trans('admin/labels/message.invalid_return_type', [
- 'name' => 'getHeight()',
- 'expected' => 'float',
- 'actual' => gettype($height)
- ]));
+ throw new \UnexpectedValueException(
+ trans(
+ 'admin/labels/message.invalid_return_type', [
+ 'name' => 'getHeight()',
+ 'expected' => 'float',
+ 'actual' => gettype($height)
+ ]
+ )
+ );
}
}
- private function validateMargins() : void {
+ private function validateMargins() : void
+ {
$marginTop = $this->getMarginTop();
if (!is_numeric($marginTop) || is_string($marginTop)) {
- throw new \UnexpectedValueException(trans('admin/labels/message.invalid_return_type', [
- 'name' => 'getMarginTop()',
- 'expected' => 'float',
- 'actual' => gettype($marginTop)
- ]));
+ throw new \UnexpectedValueException(
+ trans(
+ 'admin/labels/message.invalid_return_type', [
+ 'name' => 'getMarginTop()',
+ 'expected' => 'float',
+ 'actual' => gettype($marginTop)
+ ]
+ )
+ );
}
$marginBottom = $this->getMarginBottom();
if (!is_numeric($marginBottom) || is_string($marginBottom)) {
- throw new \UnexpectedValueException(trans('admin/labels/message.invalid_return_type', [
- 'name' => 'getMarginBottom()',
- 'expected' => 'float',
- 'actual' => gettype($marginBottom)
- ]));
+ throw new \UnexpectedValueException(
+ trans(
+ 'admin/labels/message.invalid_return_type', [
+ 'name' => 'getMarginBottom()',
+ 'expected' => 'float',
+ 'actual' => gettype($marginBottom)
+ ]
+ )
+ );
}
$marginLeft = $this->getMarginLeft();
if (!is_numeric($marginLeft) || is_string($marginLeft)) {
- throw new \UnexpectedValueException(trans('admin/labels/message.invalid_return_type', [
- 'name' => 'getMarginLeft()',
- 'expected' => 'float',
- 'actual' => gettype($marginLeft)
- ]));
+ throw new \UnexpectedValueException(
+ trans(
+ 'admin/labels/message.invalid_return_type', [
+ 'name' => 'getMarginLeft()',
+ 'expected' => 'float',
+ 'actual' => gettype($marginLeft)
+ ]
+ )
+ );
}
$marginRight = $this->getMarginRight();
if (!is_numeric($marginRight) || is_string($marginRight)) {
- throw new \UnexpectedValueException(trans('admin/labels/message.invalid_return_type', [
- 'name' => 'getMarginRight()',
- 'expected' => 'float',
- 'actual' => gettype($marginRight)
- ]));
+ throw new \UnexpectedValueException(
+ trans(
+ 'admin/labels/message.invalid_return_type', [
+ 'name' => 'getMarginRight()',
+ 'expected' => 'float',
+ 'actual' => gettype($marginRight)
+ ]
+ )
+ );
}
}
- private function validateSupport() : void {
+ private function validateSupport() : void
+ {
$support1D = $this->getSupport1DBarcode();
if (!is_bool($support1D)) {
- throw new \UnexpectedValueException(trans('admin/labels/message.invalid_return_type', [
- 'name' => 'getSupport1DBarcode()',
- 'expected' => 'boolean',
- 'actual' => gettype($support1D)
- ]));
+ throw new \UnexpectedValueException(
+ trans(
+ 'admin/labels/message.invalid_return_type', [
+ 'name' => 'getSupport1DBarcode()',
+ 'expected' => 'boolean',
+ 'actual' => gettype($support1D)
+ ]
+ )
+ );
}
$support2D = $this->getSupport2DBarcode();
if (!is_bool($support2D)) {
- throw new \UnexpectedValueException(trans('admin/labels/message.invalid_return_type', [
- 'name' => 'getSupport2DBarcode()',
- 'expected' => 'boolean',
- 'actual' => gettype($support2D)
- ]));
+ throw new \UnexpectedValueException(
+ trans(
+ 'admin/labels/message.invalid_return_type', [
+ 'name' => 'getSupport2DBarcode()',
+ 'expected' => 'boolean',
+ 'actual' => gettype($support2D)
+ ]
+ )
+ );
}
$supportFields = $this->getSupportFields();
if (!is_int($supportFields)) {
- throw new \UnexpectedValueException(trans('admin/labels/message.invalid_return_type', [
- 'name' => 'getSupportFields()',
- 'expected' => 'integer',
- 'actual' => gettype($supportFields)
- ]));
+ throw new \UnexpectedValueException(
+ trans(
+ 'admin/labels/message.invalid_return_type', [
+ 'name' => 'getSupportFields()',
+ 'expected' => 'integer',
+ 'actual' => gettype($supportFields)
+ ]
+ )
+ );
}
$supportLogo = $this->getSupportLogo();
if (!is_bool($supportLogo)) {
- throw new \UnexpectedValueException(trans('admin/labels/message.invalid_return_type', [
- 'name' => 'getSupportLogo()',
- 'expected' => 'boolean',
- 'actual' => gettype($supportLogo)
- ]));
+ throw new \UnexpectedValueException(
+ trans(
+ 'admin/labels/message.invalid_return_type', [
+ 'name' => 'getSupportLogo()',
+ 'expected' => 'boolean',
+ 'actual' => gettype($supportLogo)
+ ]
+ )
+ );
}
$supportTitle = $this->getSupportTitle();
if (!is_bool($supportTitle)) {
- throw new \UnexpectedValueException(trans('admin/labels/message.invalid_return_type', [
- 'name' => 'getSupportTitle()',
- 'expected' => 'boolean',
- 'actual' => gettype($supportTitle)
- ]));
+ throw new \UnexpectedValueException(
+ trans(
+ 'admin/labels/message.invalid_return_type', [
+ 'name' => 'getSupportTitle()',
+ 'expected' => 'boolean',
+ 'actual' => gettype($supportTitle)
+ ]
+ )
+ );
}
}
@@ -539,23 +627,26 @@ abstract class Label
/**
* Public Static Functions
- */
+ */
/**
* Find size of a page by its format.
*
- * @param string $format Format name (eg: 'A4', 'LETTER', etc.)
- * @param string $orientation 'L' for Landscape, 'P' for Portrait ('L' default)
- * @param string $unit Unit of measure to return in ('mm' default)
+ * @param string $format Format name (eg: 'A4', 'LETTER', etc.)
+ * @param string $orientation 'L' for Landscape, 'P' for Portrait ('L' default)
+ * @param string $unit Unit of measure to return in ('mm' default)
*
* @return object (object)[ 'width' => (float)123.4, 'height' => (float)123.4 ]
*/
- public static function fromFormat($format, $orientation='L', $unit='mm', $round=false) {
+ public static function fromFormat($format, $orientation='L', $unit='mm', $round=false)
+ {
$size = collect(TCPDF_STATIC::getPageSizeFromFormat(strtoupper($format)))
->sort()
- ->map(function ($value) use ($unit) {
- return Helper::convertUnit($value, 'pt', $unit);
- })
+ ->map(
+ function ($value) use ($unit) {
+ return Helper::convertUnit($value, 'pt', $unit);
+ }
+ )
->toArray();
$width = ($orientation == 'L') ? $size[1] : $size[0];
$height = ($orientation == 'L') ? $size[0] : $size[1];
@@ -571,16 +662,19 @@ abstract class Label
* Unlike most Models, these are defined by their existence as non-
* abstract classes stored in Models\Labels.
*
- * @param string|Arrayable|array|null $path Label path[s]
+ * @param string|Arrayable|array|null $path Label path[s]
* @return Collection|Label|null
*/
- public static function find($name=null) {
+ public static function find($name=null)
+ {
// Find many
if (is_array($name) || $name instanceof Arrayable) {
$labels = collect($name)
- ->map(function ($thisname) {
- return static::find($thisname);
- })
+ ->map(
+ function ($thisname) {
+ return static::find($thisname);
+ }
+ )
->whereNotNull();
return ($labels->count() > 0) ? $labels : null;
}
@@ -588,26 +682,36 @@ abstract class Label
// Find one
if ($name !== null) {
return static::find()
- ->sole(function ($label) use ($name) {
- return $label->getName() == $name;
- });
+ ->sole(
+ function ($label) use ($name) {
+ return $label->getName() == $name;
+ }
+ );
}
// Find all
return collect(File::allFiles(__DIR__))
- ->map(function ($file) {
- preg_match_all('/\/*(.+?)(?:\/|\.)/', $file->getRelativePathName(), $matches);
- return __NAMESPACE__ . '\\' . implode('\\', $matches[1]);
- })
- ->filter(function ($name) {
- if (!class_exists($name)) return false;
- $refClass = new \ReflectionClass($name);
- if ($refClass->isAbstract()) return false;
- return $refClass->isSubclassOf(Label::class);
- })
- ->map(function ($name) {
- return new $name();
- });
+ ->map(
+ function ($file) {
+ preg_match_all('/\/*(.+?)(?:\/|\.)/', $file->getRelativePathName(), $matches);
+ return __NAMESPACE__ . '\\' . implode('\\', $matches[1]);
+ }
+ )
+ ->filter(
+ function ($name) {
+ if (!class_exists($name)) { return false;
+ }
+ $refClass = new \ReflectionClass($name);
+ if ($refClass->isAbstract()) { return false;
+ }
+ return $refClass->isSubclassOf(Label::class);
+ }
+ )
+ ->map(
+ function ($name) {
+ return new $name();
+ }
+ );
}
diff --git a/app/Models/Labels/RectangleSheet.php b/app/Models/Labels/RectangleSheet.php
index f5fe5cda98..e9c6f007d9 100644
--- a/app/Models/Labels/RectangleSheet.php
+++ b/app/Models/Labels/RectangleSheet.php
@@ -33,9 +33,13 @@ abstract class RectangleSheet extends Sheet
public abstract function getLabelRowSpacing();
- public function getLabelsPerPage() { return $this->getColumns() * $this->getRows(); }
+ public function getLabelsPerPage()
+ {
+ return $this->getColumns() * $this->getRows();
+ }
- public function getLabelPosition($index) {
+ public function getLabelPosition($index)
+ {
$printIndex = $index + $this->getLabelIndexOffset();
$row = (int)($printIndex / $this->getColumns());
$col = $printIndex - ($row * $this->getColumns());
diff --git a/app/Models/Labels/Sheet.php b/app/Models/Labels/Sheet.php
index 83e363591a..63f9da173a 100644
--- a/app/Models/Labels/Sheet.php
+++ b/app/Models/Labels/Sheet.php
@@ -6,12 +6,30 @@ abstract class Sheet extends Label
{
protected int $indexOffset = 0;
- public function getWidth() { return $this->getPageWidth(); }
- public function getHeight() { return $this->getPageHeight(); }
- public function getMarginTop() { return $this->getPageMarginTop(); }
- public function getMarginBottom() { return $this->getPageMarginBottom(); }
- public function getMarginLeft() { return $this->getPageMarginLeft(); }
- public function getMarginRight() { return $this->getPageMarginRight(); }
+ public function getWidth()
+ {
+ return $this->getPageWidth();
+ }
+ public function getHeight()
+ {
+ return $this->getPageHeight();
+ }
+ public function getMarginTop()
+ {
+ return $this->getPageMarginTop();
+ }
+ public function getMarginBottom()
+ {
+ return $this->getPageMarginBottom();
+ }
+ public function getMarginLeft()
+ {
+ return $this->getPageMarginLeft();
+ }
+ public function getMarginRight()
+ {
+ return $this->getPageMarginRight();
+ }
/**
* Returns the page width in getUnit() units
@@ -107,7 +125,7 @@ abstract class Sheet extends Label
/**
* Returns label position based on its index
*
- * @param int $index
+ * @param int $index
*
* @return array [x,y]
*/
@@ -123,10 +141,11 @@ abstract class Sheet extends Label
/**
* Handle the data here. Override for multiple-per-page handling
*
- * @param TCPDF $pdf The TCPDF instance
- * @param Collection $data The data
+ * @param TCPDF $pdf The TCPDF instance
+ * @param Collection $data The data
*/
- public function writeAll($pdf, $data) {
+ public function writeAll($pdf, $data)
+ {
$prevPageNumber = -1;
foreach ($data->toArray() as $recordIndex => $record) {
@@ -170,7 +189,8 @@ abstract class Sheet extends Label
*
* @return string
*/
- public final function getLabelOrientation() {
+ public final function getLabelOrientation()
+ {
return ($this->getLabelWidth() >= $this->getLabelHeight()) ? 'L' : 'P';
}
@@ -179,7 +199,8 @@ abstract class Sheet extends Label
*
* @return object [ 'x1'=>0.00, 'y1'=>0.00, 'x2'=>0.00, 'y2'=>0.00, 'w'=>0.00, 'h'=>0.00 ]
*/
- public final function getLabelPrintableArea() {
+ public final function getLabelPrintableArea()
+ {
return (object)[
'x1' => $this->getLabelMarginLeft(),
'y1' => $this->getLabelMarginTop(),
@@ -195,15 +216,20 @@ abstract class Sheet extends Label
*
* @return int
*/
- public function getLabelIndexOffset() { return $this->indexOffset; }
+ public function getLabelIndexOffset()
+ {
+ return $this->indexOffset;
+ }
/**
* Sets label index offset (skip positions)
*
- * @param int $offset
- *
+ * @param int $offset
*/
- public function setLabelIndexOffset(int $offset) { $this->indexOffset = $offset; }
+ public function setLabelIndexOffset(int $offset)
+ {
+ $this->indexOffset = $offset;
+ }
}
?>
\ No newline at end of file
diff --git a/app/Models/Labels/Sheets/Avery/L7162.php b/app/Models/Labels/Sheets/Avery/L7162.php
index e1097db9b2..d0e6c673c7 100644
--- a/app/Models/Labels/Sheets/Avery/L7162.php
+++ b/app/Models/Labels/Sheets/Avery/L7162.php
@@ -31,7 +31,8 @@ abstract class L7162 extends RectangleSheet
private float $labelWidth;
private float $labelHeight;
- public function __construct() {
+ public function __construct()
+ {
$paperSize = static::fromFormat(self::PAPER_FORMAT, self::PAPER_ORIENTATION, $this->getUnit(), 0);
$this->pageWidth = $paperSize->width;
$this->pageHeight = $paperSize->height;
@@ -48,24 +49,63 @@ abstract class L7162 extends RectangleSheet
$this->labelHeight = Helper::convertUnit(self::LABEL_H, 'pt', $this->getUnit());
}
- public function getPageWidth() { return $this->pageWidth; }
- public function getPageHeight() { return $this->pageHeight; }
+ public function getPageWidth()
+ {
+ return $this->pageWidth;
+ }
+ public function getPageHeight()
+ {
+ return $this->pageHeight;
+ }
- public function getPageMarginTop() { return $this->pageMarginTop; }
- public function getPageMarginBottom() { return $this->pageMarginTop; }
- public function getPageMarginLeft() { return $this->pageMarginLeft; }
- public function getPageMarginRight() { return $this->pageMarginLeft; }
+ public function getPageMarginTop()
+ {
+ return $this->pageMarginTop;
+ }
+ public function getPageMarginBottom()
+ {
+ return $this->pageMarginTop;
+ }
+ public function getPageMarginLeft()
+ {
+ return $this->pageMarginLeft;
+ }
+ public function getPageMarginRight()
+ {
+ return $this->pageMarginLeft;
+ }
- public function getColumns() { return 2; }
- public function getRows() { return 8; }
+ public function getColumns()
+ {
+ return 2;
+ }
+ public function getRows()
+ {
+ return 8;
+ }
- public function getLabelColumnSpacing() { return $this->columnSpacing; }
- public function getLabelRowSpacing() { return $this->rowSpacing; }
+ public function getLabelColumnSpacing()
+ {
+ return $this->columnSpacing;
+ }
+ public function getLabelRowSpacing()
+ {
+ return $this->rowSpacing;
+ }
- public function getLabelWidth() { return $this->labelWidth; }
- public function getLabelHeight() { return $this->labelHeight; }
+ public function getLabelWidth()
+ {
+ return $this->labelWidth;
+ }
+ public function getLabelHeight()
+ {
+ return $this->labelHeight;
+ }
- public function getLabelBorder() { return 0; }
+ public function getLabelBorder()
+ {
+ return 0;
+ }
}
?>
\ No newline at end of file
diff --git a/app/Models/Labels/Sheets/Avery/L7162_A.php b/app/Models/Labels/Sheets/Avery/L7162_A.php
index 0b3312ba7c..adfe7f382a 100644
--- a/app/Models/Labels/Sheets/Avery/L7162_A.php
+++ b/app/Models/Labels/Sheets/Avery/L7162_A.php
@@ -14,23 +14,59 @@ class L7162_A extends L7162
private const FIELD_SIZE = 4.60;
private const FIELD_MARGIN = 0.30;
- public function getUnit() { return 'mm'; }
+ public function getUnit()
+ {
+ return 'mm';
+ }
- public function getLabelMarginTop() { return 1.0; }
- public function getLabelMarginBottom() { return 1.0; }
- public function getLabelMarginLeft() { return 1.0; }
- public function getLabelMarginRight() { return 1.0; }
+ public function getLabelMarginTop()
+ {
+ return 1.0;
+ }
+ public function getLabelMarginBottom()
+ {
+ return 1.0;
+ }
+ public function getLabelMarginLeft()
+ {
+ return 1.0;
+ }
+ public function getLabelMarginRight()
+ {
+ return 1.0;
+ }
- public function getSupportAssetTag() { return true; }
- public function getSupport1DBarcode() { return false; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 4; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return true; }
+ public function getSupportAssetTag()
+ {
+ return true;
+ }
+ public function getSupport1DBarcode()
+ {
+ return false;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 4;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getLabelPrintableArea();
$usableWidth = $pa->w;
diff --git a/app/Models/Labels/Sheets/Avery/L7162_B.php b/app/Models/Labels/Sheets/Avery/L7162_B.php
index 9f24d58c2f..833653cabf 100644
--- a/app/Models/Labels/Sheets/Avery/L7162_B.php
+++ b/app/Models/Labels/Sheets/Avery/L7162_B.php
@@ -17,23 +17,59 @@ class L7162_B extends L7162
private const FIELD_SIZE = 4.20;
private const FIELD_MARGIN = 0.30;
- public function getUnit() { return 'mm'; }
+ public function getUnit()
+ {
+ return 'mm';
+ }
- public function getLabelMarginTop() { return 1.0; }
- public function getLabelMarginBottom() { return 0; }
- public function getLabelMarginLeft() { return 1.0; }
- public function getLabelMarginRight() { return 1.0; }
+ public function getLabelMarginTop()
+ {
+ return 1.0;
+ }
+ public function getLabelMarginBottom()
+ {
+ return 0;
+ }
+ public function getLabelMarginLeft()
+ {
+ return 1.0;
+ }
+ public function getLabelMarginRight()
+ {
+ return 1.0;
+ }
- public function getSupportAssetTag() { return true; }
- public function getSupport1DBarcode() { return true; }
- public function getSupport2DBarcode() { return false; }
- public function getSupportFields() { return 3; }
- public function getSupportLogo() { return true; }
- public function getSupportTitle() { return true; }
+ public function getSupportAssetTag()
+ {
+ return true;
+ }
+ public function getSupport1DBarcode()
+ {
+ return true;
+ }
+ public function getSupport2DBarcode()
+ {
+ return false;
+ }
+ public function getSupportFields()
+ {
+ return 3;
+ }
+ public function getSupportLogo()
+ {
+ return true;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getLabelPrintableArea();
$usableWidth = $pa->w;
diff --git a/app/Models/Labels/Sheets/Avery/L7163.php b/app/Models/Labels/Sheets/Avery/L7163.php
index f143260336..01fe9a78e0 100644
--- a/app/Models/Labels/Sheets/Avery/L7163.php
+++ b/app/Models/Labels/Sheets/Avery/L7163.php
@@ -31,7 +31,8 @@ abstract class L7163 extends RectangleSheet
private float $labelWidth;
private float $labelHeight;
- public function __construct() {
+ public function __construct()
+ {
$paperSize = static::fromFormat(self::PAPER_FORMAT, self::PAPER_ORIENTATION, $this->getUnit(), 0);
$this->pageWidth = $paperSize->width;
$this->pageHeight = $paperSize->height;
@@ -48,24 +49,63 @@ abstract class L7163 extends RectangleSheet
$this->labelHeight = Helper::convertUnit(self::LABEL_H, 'pt', $this->getUnit());
}
- public function getPageWidth() { return $this->pageWidth; }
- public function getPageHeight() { return $this->pageHeight; }
+ public function getPageWidth()
+ {
+ return $this->pageWidth;
+ }
+ public function getPageHeight()
+ {
+ return $this->pageHeight;
+ }
- public function getPageMarginTop() { return $this->pageMarginTop; }
- public function getPageMarginBottom() { return $this->pageMarginTop; }
- public function getPageMarginLeft() { return $this->pageMarginLeft; }
- public function getPageMarginRight() { return $this->pageMarginLeft; }
+ public function getPageMarginTop()
+ {
+ return $this->pageMarginTop;
+ }
+ public function getPageMarginBottom()
+ {
+ return $this->pageMarginTop;
+ }
+ public function getPageMarginLeft()
+ {
+ return $this->pageMarginLeft;
+ }
+ public function getPageMarginRight()
+ {
+ return $this->pageMarginLeft;
+ }
- public function getColumns() { return 2; }
- public function getRows() { return 7; }
+ public function getColumns()
+ {
+ return 2;
+ }
+ public function getRows()
+ {
+ return 7;
+ }
- public function getLabelColumnSpacing() { return $this->columnSpacing; }
- public function getLabelRowSpacing() { return $this->rowSpacing; }
+ public function getLabelColumnSpacing()
+ {
+ return $this->columnSpacing;
+ }
+ public function getLabelRowSpacing()
+ {
+ return $this->rowSpacing;
+ }
- public function getLabelWidth() { return $this->labelWidth; }
- public function getLabelHeight() { return $this->labelHeight; }
+ public function getLabelWidth()
+ {
+ return $this->labelWidth;
+ }
+ public function getLabelHeight()
+ {
+ return $this->labelHeight;
+ }
- public function getLabelBorder() { return 0; }
+ public function getLabelBorder()
+ {
+ return 0;
+ }
}
?>
\ No newline at end of file
diff --git a/app/Models/Labels/Sheets/Avery/L7163_A.php b/app/Models/Labels/Sheets/Avery/L7163_A.php
index 6dc33f64dd..47a44d75db 100644
--- a/app/Models/Labels/Sheets/Avery/L7163_A.php
+++ b/app/Models/Labels/Sheets/Avery/L7163_A.php
@@ -14,23 +14,59 @@ class L7163_A extends L7163
private const FIELD_SIZE = 4.80;
private const FIELD_MARGIN = 0.30;
- public function getUnit() { return 'mm'; }
+ public function getUnit()
+ {
+ return 'mm';
+ }
- public function getLabelMarginTop() { return 1.0; }
- public function getLabelMarginBottom() { return 1.0; }
- public function getLabelMarginLeft() { return 1.0; }
- public function getLabelMarginRight() { return 1.0; }
+ public function getLabelMarginTop()
+ {
+ return 1.0;
+ }
+ public function getLabelMarginBottom()
+ {
+ return 1.0;
+ }
+ public function getLabelMarginLeft()
+ {
+ return 1.0;
+ }
+ public function getLabelMarginRight()
+ {
+ return 1.0;
+ }
- public function getSupportAssetTag() { return true; }
- public function getSupport1DBarcode() { return false; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 4; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return true; }
+ public function getSupportAssetTag()
+ {
+ return true;
+ }
+ public function getSupport1DBarcode()
+ {
+ return false;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 4;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getLabelPrintableArea();
$usableWidth = $pa->w;
diff --git a/app/Models/Labels/Sheets/Avery/_3490.php b/app/Models/Labels/Sheets/Avery/_3490.php
index 2782549fd3..c81c980e11 100644
--- a/app/Models/Labels/Sheets/Avery/_3490.php
+++ b/app/Models/Labels/Sheets/Avery/_3490.php
@@ -31,7 +31,8 @@ abstract class _3490 extends RectangleSheet
private float $labelWidth;
private float $labelHeight;
- public function __construct() {
+ public function __construct()
+ {
$paperSize = static::fromFormat(self::PAPER_FORMAT, self::PAPER_ORIENTATION, $this->getUnit(), 2);
$this->pageWidth = $paperSize->width;
$this->pageHeight = $paperSize->height;
@@ -48,24 +49,63 @@ abstract class _3490 extends RectangleSheet
$this->labelHeight = Helper::convertUnit(self::LABEL_H, 'pt', $this->getUnit());
}
- public function getPageWidth() { return $this->pageWidth; }
- public function getPageHeight() { return $this->pageHeight; }
+ public function getPageWidth()
+ {
+ return $this->pageWidth;
+ }
+ public function getPageHeight()
+ {
+ return $this->pageHeight;
+ }
- public function getPageMarginTop() { return $this->pageMarginTop; }
- public function getPageMarginBottom() { return $this->pageMarginTop; }
- public function getPageMarginLeft() { return $this->pageMarginLeft; }
- public function getPageMarginRight() { return $this->pageMarginLeft; }
+ public function getPageMarginTop()
+ {
+ return $this->pageMarginTop;
+ }
+ public function getPageMarginBottom()
+ {
+ return $this->pageMarginTop;
+ }
+ public function getPageMarginLeft()
+ {
+ return $this->pageMarginLeft;
+ }
+ public function getPageMarginRight()
+ {
+ return $this->pageMarginLeft;
+ }
- public function getColumns() { return 3; }
- public function getRows() { return 10; }
+ public function getColumns()
+ {
+ return 3;
+ }
+ public function getRows()
+ {
+ return 10;
+ }
- public function getLabelColumnSpacing() { return $this->columnSpacing; }
- public function getLabelRowSpacing() { return $this->rowSpacing; }
+ public function getLabelColumnSpacing()
+ {
+ return $this->columnSpacing;
+ }
+ public function getLabelRowSpacing()
+ {
+ return $this->rowSpacing;
+ }
- public function getLabelWidth() { return $this->labelWidth; }
- public function getLabelHeight() { return $this->labelHeight; }
+ public function getLabelWidth()
+ {
+ return $this->labelWidth;
+ }
+ public function getLabelHeight()
+ {
+ return $this->labelHeight;
+ }
- public function getLabelBorder() { return 0; }
+ public function getLabelBorder()
+ {
+ return 0;
+ }
}
?>
\ No newline at end of file
diff --git a/app/Models/Labels/Sheets/Avery/_3490_A.php b/app/Models/Labels/Sheets/Avery/_3490_A.php
index c558e22292..591f8318aa 100644
--- a/app/Models/Labels/Sheets/Avery/_3490_A.php
+++ b/app/Models/Labels/Sheets/Avery/_3490_A.php
@@ -14,23 +14,59 @@ class _3490_A extends _3490
private const FIELD_SIZE = 0.150;
private const FIELD_MARGIN = 0.012;
- public function getUnit() { return 'in'; }
+ public function getUnit()
+ {
+ return 'in';
+ }
- public function getLabelMarginTop() { return 0.06; }
- public function getLabelMarginBottom() { return 0.06; }
- public function getLabelMarginLeft() { return 0.06; }
- public function getLabelMarginRight() { return 0.06; }
+ public function getLabelMarginTop()
+ {
+ return 0.06;
+ }
+ public function getLabelMarginBottom()
+ {
+ return 0.06;
+ }
+ public function getLabelMarginLeft()
+ {
+ return 0.06;
+ }
+ public function getLabelMarginRight()
+ {
+ return 0.06;
+ }
- public function getSupportAssetTag() { return false; }
- public function getSupport1DBarcode() { return false; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 3; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return true; }
+ public function getSupportAssetTag()
+ {
+ return false;
+ }
+ public function getSupport1DBarcode()
+ {
+ return false;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 3;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getLabelPrintableArea();
$currentX = $pa->x1;
diff --git a/app/Models/Labels/Sheets/Avery/_5267.php b/app/Models/Labels/Sheets/Avery/_5267.php
index f5f2f13557..882c862691 100644
--- a/app/Models/Labels/Sheets/Avery/_5267.php
+++ b/app/Models/Labels/Sheets/Avery/_5267.php
@@ -31,7 +31,8 @@ abstract class _5267 extends RectangleSheet
private float $labelWidth;
private float $labelHeight;
- public function __construct() {
+ public function __construct()
+ {
$paperSize = static::fromFormat(self::PAPER_FORMAT, self::PAPER_ORIENTATION, $this->getUnit(), 2);
$this->pageWidth = $paperSize->width;
$this->pageHeight = $paperSize->height;
@@ -48,24 +49,63 @@ abstract class _5267 extends RectangleSheet
$this->labelHeight = Helper::convertUnit(self::LABEL_H, 'pt', $this->getUnit());
}
- public function getPageWidth() { return $this->pageWidth; }
- public function getPageHeight() { return $this->pageHeight; }
+ public function getPageWidth()
+ {
+ return $this->pageWidth;
+ }
+ public function getPageHeight()
+ {
+ return $this->pageHeight;
+ }
- public function getPageMarginTop() { return $this->pageMarginTop; }
- public function getPageMarginBottom() { return $this->pageMarginTop; }
- public function getPageMarginLeft() { return $this->pageMarginLeft; }
- public function getPageMarginRight() { return $this->pageMarginLeft; }
+ public function getPageMarginTop()
+ {
+ return $this->pageMarginTop;
+ }
+ public function getPageMarginBottom()
+ {
+ return $this->pageMarginTop;
+ }
+ public function getPageMarginLeft()
+ {
+ return $this->pageMarginLeft;
+ }
+ public function getPageMarginRight()
+ {
+ return $this->pageMarginLeft;
+ }
- public function getColumns() { return 4; }
- public function getRows() { return 20; }
+ public function getColumns()
+ {
+ return 4;
+ }
+ public function getRows()
+ {
+ return 20;
+ }
- public function getLabelColumnSpacing() { return $this->columnSpacing; }
- public function getLabelRowSpacing() { return $this->rowSpacing; }
+ public function getLabelColumnSpacing()
+ {
+ return $this->columnSpacing;
+ }
+ public function getLabelRowSpacing()
+ {
+ return $this->rowSpacing;
+ }
- public function getLabelWidth() { return $this->labelWidth; }
- public function getLabelHeight() { return $this->labelHeight; }
+ public function getLabelWidth()
+ {
+ return $this->labelWidth;
+ }
+ public function getLabelHeight()
+ {
+ return $this->labelHeight;
+ }
- public function getLabelBorder() { return 0; }
+ public function getLabelBorder()
+ {
+ return 0;
+ }
}
?>
\ No newline at end of file
diff --git a/app/Models/Labels/Sheets/Avery/_5267_A.php b/app/Models/Labels/Sheets/Avery/_5267_A.php
index efe0855d5e..1ed6f557f0 100644
--- a/app/Models/Labels/Sheets/Avery/_5267_A.php
+++ b/app/Models/Labels/Sheets/Avery/_5267_A.php
@@ -12,23 +12,59 @@ class _5267_A extends _5267
private const FIELD_SIZE = 0.150;
private const FIELD_MARGIN = 0.012;
- public function getUnit() { return 'in'; }
+ public function getUnit()
+ {
+ return 'in';
+ }
- public function getLabelMarginTop() { return 0.02; }
- public function getLabelMarginBottom() { return 0.00; }
- public function getLabelMarginLeft() { return 0.04; }
- public function getLabelMarginRight() { return 0.04; }
+ public function getLabelMarginTop()
+ {
+ return 0.02;
+ }
+ public function getLabelMarginBottom()
+ {
+ return 0.00;
+ }
+ public function getLabelMarginLeft()
+ {
+ return 0.04;
+ }
+ public function getLabelMarginRight()
+ {
+ return 0.04;
+ }
- public function getSupportAssetTag() { return false; }
- public function getSupport1DBarcode() { return true; }
- public function getSupport2DBarcode() { return false; }
- public function getSupportFields() { return 1; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return true; }
+ public function getSupportAssetTag()
+ {
+ return false;
+ }
+ public function getSupport1DBarcode()
+ {
+ return true;
+ }
+ public function getSupport2DBarcode()
+ {
+ return false;
+ }
+ public function getSupportFields()
+ {
+ return 1;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getLabelPrintableArea();
if ($record->has('barcode1d')) {
diff --git a/app/Models/Labels/Sheets/Avery/_5520.php b/app/Models/Labels/Sheets/Avery/_5520.php
index 00cb0e0687..ae9ff0b039 100644
--- a/app/Models/Labels/Sheets/Avery/_5520.php
+++ b/app/Models/Labels/Sheets/Avery/_5520.php
@@ -31,7 +31,8 @@ abstract class _5520 extends RectangleSheet
private float $labelWidth;
private float $labelHeight;
- public function __construct() {
+ public function __construct()
+ {
$paperSize = static::fromFormat(self::PAPER_FORMAT, self::PAPER_ORIENTATION, $this->getUnit(), 2);
$this->pageWidth = $paperSize->width;
$this->pageHeight = $paperSize->height;
@@ -48,24 +49,63 @@ abstract class _5520 extends RectangleSheet
$this->labelHeight = Helper::convertUnit(self::LABEL_H, 'pt', $this->getUnit());
}
- public function getPageWidth() { return $this->pageWidth; }
- public function getPageHeight() { return $this->pageHeight; }
+ public function getPageWidth()
+ {
+ return $this->pageWidth;
+ }
+ public function getPageHeight()
+ {
+ return $this->pageHeight;
+ }
- public function getPageMarginTop() { return $this->pageMarginTop; }
- public function getPageMarginBottom() { return $this->pageMarginTop; }
- public function getPageMarginLeft() { return $this->pageMarginLeft; }
- public function getPageMarginRight() { return $this->pageMarginLeft; }
+ public function getPageMarginTop()
+ {
+ return $this->pageMarginTop;
+ }
+ public function getPageMarginBottom()
+ {
+ return $this->pageMarginTop;
+ }
+ public function getPageMarginLeft()
+ {
+ return $this->pageMarginLeft;
+ }
+ public function getPageMarginRight()
+ {
+ return $this->pageMarginLeft;
+ }
- public function getColumns() { return 3; }
- public function getRows() { return 10; }
+ public function getColumns()
+ {
+ return 3;
+ }
+ public function getRows()
+ {
+ return 10;
+ }
- public function getLabelColumnSpacing() { return $this->columnSpacing; }
- public function getLabelRowSpacing() { return $this->rowSpacing; }
+ public function getLabelColumnSpacing()
+ {
+ return $this->columnSpacing;
+ }
+ public function getLabelRowSpacing()
+ {
+ return $this->rowSpacing;
+ }
- public function getLabelWidth() { return $this->labelWidth; }
- public function getLabelHeight() { return $this->labelHeight; }
+ public function getLabelWidth()
+ {
+ return $this->labelWidth;
+ }
+ public function getLabelHeight()
+ {
+ return $this->labelHeight;
+ }
- public function getLabelBorder() { return 0; }
+ public function getLabelBorder()
+ {
+ return 0;
+ }
}
?>
\ No newline at end of file
diff --git a/app/Models/Labels/Sheets/Avery/_5520_A.php b/app/Models/Labels/Sheets/Avery/_5520_A.php
index 199566d248..9d2c91502d 100644
--- a/app/Models/Labels/Sheets/Avery/_5520_A.php
+++ b/app/Models/Labels/Sheets/Avery/_5520_A.php
@@ -14,23 +14,59 @@ class _5520_A extends _5520
private const FIELD_SIZE = 0.150;
private const FIELD_MARGIN = 0.012;
- public function getUnit() { return 'in'; }
+ public function getUnit()
+ {
+ return 'in';
+ }
- public function getLabelMarginTop() { return 0.06; }
- public function getLabelMarginBottom() { return 0.06; }
- public function getLabelMarginLeft() { return 0.06; }
- public function getLabelMarginRight() { return 0.06; }
+ public function getLabelMarginTop()
+ {
+ return 0.06;
+ }
+ public function getLabelMarginBottom()
+ {
+ return 0.06;
+ }
+ public function getLabelMarginLeft()
+ {
+ return 0.06;
+ }
+ public function getLabelMarginRight()
+ {
+ return 0.06;
+ }
- public function getSupportAssetTag() { return false; }
- public function getSupport1DBarcode() { return false; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 3; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return true; }
+ public function getSupportAssetTag()
+ {
+ return false;
+ }
+ public function getSupport1DBarcode()
+ {
+ return false;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 3;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getLabelPrintableArea();
$currentX = $pa->x1;
diff --git a/app/Models/Labels/Sheets/Avery/_5520_B.php b/app/Models/Labels/Sheets/Avery/_5520_B.php
index eb6494e0aa..9c44e26bf4 100644
--- a/app/Models/Labels/Sheets/Avery/_5520_B.php
+++ b/app/Models/Labels/Sheets/Avery/_5520_B.php
@@ -15,23 +15,59 @@ class _5520_B extends _5520
private const FIELD_SIZE = 0.150;
private const FIELD_MARGIN = 0.012;
- public function getUnit() { return 'in'; }
+ public function getUnit()
+ {
+ return 'in';
+ }
- public function getLabelMarginTop() { return 0.06; }
- public function getLabelMarginBottom() { return 0.06; }
- public function getLabelMarginLeft() { return 0.06; }
- public function getLabelMarginRight() { return 0.06; }
+ public function getLabelMarginTop()
+ {
+ return 0.06;
+ }
+ public function getLabelMarginBottom()
+ {
+ return 0.06;
+ }
+ public function getLabelMarginLeft()
+ {
+ return 0.06;
+ }
+ public function getLabelMarginRight()
+ {
+ return 0.06;
+ }
- public function getSupportAssetTag() { return false; }
- public function getSupport1DBarcode() { return true; }
- public function getSupport2DBarcode() { return false; }
- public function getSupportFields() { return 2; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return true; }
+ public function getSupportAssetTag()
+ {
+ return false;
+ }
+ public function getSupport1DBarcode()
+ {
+ return true;
+ }
+ public function getSupport2DBarcode()
+ {
+ return false;
+ }
+ public function getSupportFields()
+ {
+ return 2;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getLabelPrintableArea();
$currentX = $pa->x1;
diff --git a/app/Models/Labels/Tapes/Brother/TZe_12mm.php b/app/Models/Labels/Tapes/Brother/TZe_12mm.php
index f9196847ce..3cf1f54081 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_12mm.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_12mm.php
@@ -11,9 +11,24 @@ abstract class TZe_12mm extends Label
private const MARGIN_SIDES = 3.20;
private const MARGIN_ENDS = 3.20;
- public function getHeight() { return Helper::convertUnit(self::HEIGHT, 'mm', $this->getUnit()); }
- public function getMarginTop() { return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit()); }
- public function getMarginBottom() { return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit());}
- public function getMarginLeft() { return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit()); }
- public function getMarginRight() { return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit()); }
+ public function getHeight()
+ {
+ return Helper::convertUnit(self::HEIGHT, 'mm', $this->getUnit());
+ }
+ public function getMarginTop()
+ {
+ return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit());
+ }
+ public function getMarginBottom()
+ {
+ return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit());
+ }
+ public function getMarginLeft()
+ {
+ return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit());
+ }
+ public function getMarginRight()
+ {
+ return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit());
+ }
}
\ No newline at end of file
diff --git a/app/Models/Labels/Tapes/Brother/TZe_12mm_A.php b/app/Models/Labels/Tapes/Brother/TZe_12mm_A.php
index f89cfc5d47..5ff9fcd474 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_12mm_A.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_12mm_A.php
@@ -8,18 +8,45 @@ class TZe_12mm_A extends TZe_12mm
private const BARCODE_MARGIN = 0.30;
private const TEXT_SIZE_MOD = 1.00;
- public function getUnit() { return 'mm'; }
- public function getWidth() { return 50.0; }
- public function getSupportAssetTag() { return true; }
- public function getSupport1DBarcode() { return true; }
- public function getSupport2DBarcode() { return false; }
- public function getSupportFields() { return 1; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return false; }
-
- public function preparePDF($pdf) {}
-
- public function write($pdf, $record) {
+ public function getUnit()
+ {
+ return 'mm';
+ }
+ public function getWidth()
+ {
+ return 50.0;
+ }
+ public function getSupportAssetTag()
+ {
+ return true;
+ }
+ public function getSupport1DBarcode()
+ {
+ return true;
+ }
+ public function getSupport2DBarcode()
+ {
+ return false;
+ }
+ public function getSupportFields()
+ {
+ return 1;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return false;
+ }
+
+ public function preparePDF($pdf)
+ {
+ }
+
+ public function write($pdf, $record)
+ {
$pa = $this->getPrintableArea();
if ($record->has('barcode1d')) {
diff --git a/app/Models/Labels/Tapes/Brother/TZe_18mm.php b/app/Models/Labels/Tapes/Brother/TZe_18mm.php
index 38c14c7aa4..efcc405bc4 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_18mm.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_18mm.php
@@ -11,9 +11,24 @@ abstract class TZe_18mm extends Label
private const MARGIN_SIDES = 3.20;
private const MARGIN_ENDS = 3.20;
- public function getHeight() { return Helper::convertUnit(self::HEIGHT, 'mm', $this->getUnit()); }
- public function getMarginTop() { return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit()); }
- public function getMarginBottom() { return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit());}
- public function getMarginLeft() { return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit()); }
- public function getMarginRight() { return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit()); }
+ public function getHeight()
+ {
+ return Helper::convertUnit(self::HEIGHT, 'mm', $this->getUnit());
+ }
+ public function getMarginTop()
+ {
+ return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit());
+ }
+ public function getMarginBottom()
+ {
+ return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit());
+ }
+ public function getMarginLeft()
+ {
+ return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit());
+ }
+ public function getMarginRight()
+ {
+ return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit());
+ }
}
\ No newline at end of file
diff --git a/app/Models/Labels/Tapes/Brother/TZe_18mm_A.php b/app/Models/Labels/Tapes/Brother/TZe_18mm_A.php
index 32156f5ee6..fd27a80421 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_18mm_A.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_18mm_A.php
@@ -8,18 +8,45 @@ class TZe_18mm_A extends TZe_18mm
private const BARCODE_MARGIN = 0.30;
private const TEXT_SIZE_MOD = 1.00;
- public function getUnit() { return 'mm'; }
- public function getWidth() { return 50.0; }
- public function getSupportAssetTag() { return true; }
- public function getSupport1DBarcode() { return true; }
- public function getSupport2DBarcode() { return false; }
- public function getSupportFields() { return 1; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return false; }
-
- public function preparePDF($pdf) {}
-
- public function write($pdf, $record) {
+ public function getUnit()
+ {
+ return 'mm';
+ }
+ public function getWidth()
+ {
+ return 50.0;
+ }
+ public function getSupportAssetTag()
+ {
+ return true;
+ }
+ public function getSupport1DBarcode()
+ {
+ return true;
+ }
+ public function getSupport2DBarcode()
+ {
+ return false;
+ }
+ public function getSupportFields()
+ {
+ return 1;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return false;
+ }
+
+ public function preparePDF($pdf)
+ {
+ }
+
+ public function write($pdf, $record)
+ {
$pa = $this->getPrintableArea();
if ($record->has('barcode1d')) {
diff --git a/app/Models/Labels/Tapes/Brother/TZe_24mm.php b/app/Models/Labels/Tapes/Brother/TZe_24mm.php
index 3c67bc1614..c9ee228beb 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_24mm.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_24mm.php
@@ -11,9 +11,24 @@ abstract class TZe_24mm extends Label
private const MARGIN_SIDES = 3.20;
private const MARGIN_ENDS = 3.20;
- public function getHeight() { return Helper::convertUnit(self::HEIGHT, 'mm', $this->getUnit()); }
- public function getMarginTop() { return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit()); }
- public function getMarginBottom() { return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit());}
- public function getMarginLeft() { return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit()); }
- public function getMarginRight() { return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit()); }
+ public function getHeight()
+ {
+ return Helper::convertUnit(self::HEIGHT, 'mm', $this->getUnit());
+ }
+ public function getMarginTop()
+ {
+ return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit());
+ }
+ public function getMarginBottom()
+ {
+ return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit());
+ }
+ public function getMarginLeft()
+ {
+ return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit());
+ }
+ public function getMarginRight()
+ {
+ return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit());
+ }
}
\ No newline at end of file
diff --git a/app/Models/Labels/Tapes/Brother/TZe_24mm_A.php b/app/Models/Labels/Tapes/Brother/TZe_24mm_A.php
index ea4c6c9dfb..4210bb2709 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_24mm_A.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_24mm_A.php
@@ -13,18 +13,45 @@ class TZe_24mm_A extends TZe_24mm
private const FIELD_SIZE = 3.20;
private const FIELD_MARGIN = 0.15;
- public function getUnit() { return 'mm'; }
- public function getWidth() { return 65.0; }
- public function getSupportAssetTag() { return true; }
- public function getSupport1DBarcode() { return false; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 3; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return true; }
+ public function getUnit()
+ {
+ return 'mm';
+ }
+ public function getWidth()
+ {
+ return 65.0;
+ }
+ public function getSupportAssetTag()
+ {
+ return true;
+ }
+ public function getSupport1DBarcode()
+ {
+ return false;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 3;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getPrintableArea();
$currentX = $pa->x1;
diff --git a/app/Models/Labels/Tapes/Brother/TZe_24mm_B.php b/app/Models/Labels/Tapes/Brother/TZe_24mm_B.php
index cedf5e0cbd..2ea5697316 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_24mm_B.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_24mm_B.php
@@ -15,18 +15,45 @@ class TZe_24mm_B extends TZe_24mm
private const FIELD_SIZE = 3.20;
private const FIELD_MARGIN = 0.15;
- public function getUnit() { return 'mm'; }
- public function getWidth() { return 73.0; }
- public function getSupportAssetTag() { return true; }
- public function getSupport1DBarcode() { return false; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 3; }
- public function getSupportLogo() { return true; }
- public function getSupportTitle() { return true; }
+ public function getUnit()
+ {
+ return 'mm';
+ }
+ public function getWidth()
+ {
+ return 73.0;
+ }
+ public function getSupportAssetTag()
+ {
+ return true;
+ }
+ public function getSupport1DBarcode()
+ {
+ return false;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 3;
+ }
+ public function getSupportLogo()
+ {
+ return true;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getPrintableArea();
$currentX = $pa->x1;
diff --git a/app/Models/Labels/Tapes/Brother/TZe_24mm_C.php b/app/Models/Labels/Tapes/Brother/TZe_24mm_C.php
index 65b3676bfc..e100dfa81b 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_24mm_C.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_24mm_C.php
@@ -15,18 +15,45 @@ class TZe_24mm_C extends TZe_24mm
private const FIELD_SIZE = 3.20;
private const FIELD_MARGIN = 0.15;
- public function getUnit() { return 'mm'; }
- public function getWidth() { return 34.0; }
- public function getSupportAssetTag() { return true; }
- public function getSupport1DBarcode() { return false; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 0; }
- public function getSupportLogo() { return true; }
- public function getSupportTitle() { return false; }
+ public function getUnit()
+ {
+ return 'mm';
+ }
+ public function getWidth()
+ {
+ return 34.0;
+ }
+ public function getSupportAssetTag()
+ {
+ return true;
+ }
+ public function getSupport1DBarcode()
+ {
+ return false;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 0;
+ }
+ public function getSupportLogo()
+ {
+ return true;
+ }
+ public function getSupportTitle()
+ {
+ return false;
+ }
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getPrintableArea();
$currentX = $pa->x1;
diff --git a/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php b/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php
index 990a615e53..c88e84d246 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_24mm_D.php
@@ -14,18 +14,45 @@ class TZe_24mm_D extends TZe_24mm
private const FIELD_MARGIN = 0.35;
private const BARCODE1D_SIZE = 3.00; // Size for the C128 barcode at bottom
- public function getUnit() { return 'mm'; }
- public function getWidth() { return 65.0; }
- public function getSupportAssetTag() { return true; }
- public function getSupport1DBarcode() { return true; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 3; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return true; }
+ public function getUnit()
+ {
+ return 'mm';
+ }
+ public function getWidth()
+ {
+ return 65.0;
+ }
+ public function getSupportAssetTag()
+ {
+ return true;
+ }
+ public function getSupport1DBarcode()
+ {
+ return true;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 3;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getPrintableArea();
$currentX = $pa->x1;
diff --git a/app/Models/Labels/Tapes/Brother/TZe_62mm_Landscape.php b/app/Models/Labels/Tapes/Brother/TZe_62mm_Landscape.php
index 2069927a34..1f5ee1df3d 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_62mm_Landscape.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_62mm_Landscape.php
@@ -14,10 +14,28 @@ abstract class TZe_62mm_Landscape extends Label
private const MARGIN_SIDES = 1.50;
private const MARGIN_ENDS = 1.50;
- public function getWidth() { return Helper::convertUnit(self::WIDTH, 'mm', $this->getUnit()); }
- public function getMarginTop() { return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit()); }
- public function getMarginBottom() { return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit());}
- public function getMarginLeft() { return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit()); }
- public function getMarginRight() { return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit()); }
- public function getRotation() { return 90; }
+ public function getWidth()
+ {
+ return Helper::convertUnit(self::WIDTH, 'mm', $this->getUnit());
+ }
+ public function getMarginTop()
+ {
+ return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit());
+ }
+ public function getMarginBottom()
+ {
+ return Helper::convertUnit(self::MARGIN_SIDES, 'mm', $this->getUnit());
+ }
+ public function getMarginLeft()
+ {
+ return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit());
+ }
+ public function getMarginRight()
+ {
+ return Helper::convertUnit(self::MARGIN_ENDS, 'mm', $this->getUnit());
+ }
+ public function getRotation()
+ {
+ return 90;
+ }
}
diff --git a/app/Models/Labels/Tapes/Brother/TZe_62mm_Landscape_A.php b/app/Models/Labels/Tapes/Brother/TZe_62mm_Landscape_A.php
index 3a4d6da2c7..6cf53f8e18 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_62mm_Landscape_A.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_62mm_Landscape_A.php
@@ -4,14 +4,38 @@ namespace App\Models\Labels\Tapes\Brother;
class TZe_62mm_Landscape_A extends TZe_62mm_Landscape
{
- public function getUnit() { return 'mm'; }
- public function getHeight() { return 31.50; }
- public function getSupportAssetTag() { return true; }
- public function getSupport1DBarcode() { return true; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 2; }
- public function getSupportLogo() { return true; }
- public function getSupportTitle() { return true; }
+ public function getUnit()
+ {
+ return 'mm';
+ }
+ public function getHeight()
+ {
+ return 31.50;
+ }
+ public function getSupportAssetTag()
+ {
+ return true;
+ }
+ public function getSupport1DBarcode()
+ {
+ return true;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 2;
+ }
+ public function getSupportLogo()
+ {
+ return true;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
private const BARCODE1D_HEIGHT = 3.00;
private const BARCODE1D_MARGIN = 3.00;
@@ -27,9 +51,12 @@ class TZe_62mm_Landscape_A extends TZe_62mm_Landscape
private const FIELD_SIZE = 3.00;
private const FIELD_MARGIN = 0.10;
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getPrintableArea();
$currentX = $pa->x1;
diff --git a/app/Models/Labels/Tapes/Dymo/LabelWriter.php b/app/Models/Labels/Tapes/Dymo/LabelWriter.php
index fa427fd213..8d9e37555d 100644
--- a/app/Models/Labels/Tapes/Dymo/LabelWriter.php
+++ b/app/Models/Labels/Tapes/Dymo/LabelWriter.php
@@ -11,9 +11,24 @@ abstract class LabelWriter extends Label
private const MARGIN_SIDES = 0.1;
private const MARGIN_ENDS = 0.1;
- public function getHeight() { return Helper::convertUnit(self::HEIGHT, 'in', $this->getUnit()); }
- public function getMarginTop() { return Helper::convertUnit(self::MARGIN_SIDES, 'in', $this->getUnit()); }
- public function getMarginBottom() { return Helper::convertUnit(self::MARGIN_SIDES, 'in', $this->getUnit());}
- public function getMarginLeft() { return Helper::convertUnit(self::MARGIN_ENDS, 'in', $this->getUnit()); }
- public function getMarginRight() { return Helper::convertUnit(self::MARGIN_ENDS, 'in', $this->getUnit()); }
+ public function getHeight()
+ {
+ return Helper::convertUnit(self::HEIGHT, 'in', $this->getUnit());
+ }
+ public function getMarginTop()
+ {
+ return Helper::convertUnit(self::MARGIN_SIDES, 'in', $this->getUnit());
+ }
+ public function getMarginBottom()
+ {
+ return Helper::convertUnit(self::MARGIN_SIDES, 'in', $this->getUnit());
+ }
+ public function getMarginLeft()
+ {
+ return Helper::convertUnit(self::MARGIN_ENDS, 'in', $this->getUnit());
+ }
+ public function getMarginRight()
+ {
+ return Helper::convertUnit(self::MARGIN_ENDS, 'in', $this->getUnit());
+ }
}
\ No newline at end of file
diff --git a/app/Models/Labels/Tapes/Dymo/LabelWriter_1933081.php b/app/Models/Labels/Tapes/Dymo/LabelWriter_1933081.php
index 9f5fa735e4..63c270e865 100644
--- a/app/Models/Labels/Tapes/Dymo/LabelWriter_1933081.php
+++ b/app/Models/Labels/Tapes/Dymo/LabelWriter_1933081.php
@@ -14,19 +14,49 @@ class LabelWriter_1933081 extends LabelWriter
private const FIELD_SIZE = 2.80;
private const FIELD_MARGIN = 0.15;
- public function getUnit() { return 'mm'; }
- public function getWidth() { return 89; }
- public function getHeight() { return 25; }
- public function getSupportAssetTag() { return true; }
- public function getSupport1DBarcode() { return true; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 5; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return true; }
+ public function getUnit()
+ {
+ return 'mm';
+ }
+ public function getWidth()
+ {
+ return 89;
+ }
+ public function getHeight()
+ {
+ return 25;
+ }
+ public function getSupportAssetTag()
+ {
+ return true;
+ }
+ public function getSupport1DBarcode()
+ {
+ return true;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 5;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getPrintableArea();
$currentX = $pa->x1;
diff --git a/app/Models/Labels/Tapes/Dymo/LabelWriter_2112283.php b/app/Models/Labels/Tapes/Dymo/LabelWriter_2112283.php
index 117486a8e5..63701d31a1 100644
--- a/app/Models/Labels/Tapes/Dymo/LabelWriter_2112283.php
+++ b/app/Models/Labels/Tapes/Dymo/LabelWriter_2112283.php
@@ -14,19 +14,49 @@ class LabelWriter_2112283 extends LabelWriter
private const FIELD_SIZE = 2.80;
private const FIELD_MARGIN = 0.15;
- public function getUnit() { return 'mm'; }
- public function getWidth() { return 54; }
- public function getHeight() { return 25; }
- public function getSupportAssetTag() { return true; }
- public function getSupport1DBarcode() { return true; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 5; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return true; }
+ public function getUnit()
+ {
+ return 'mm';
+ }
+ public function getWidth()
+ {
+ return 54;
+ }
+ public function getHeight()
+ {
+ return 25;
+ }
+ public function getSupportAssetTag()
+ {
+ return true;
+ }
+ public function getSupport1DBarcode()
+ {
+ return true;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 5;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {}
+ public function preparePDF($pdf)
+ {
+ }
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getPrintableArea();
$currentX = $pa->x1;
diff --git a/app/Models/Labels/Tapes/Dymo/LabelWriter_30252.php b/app/Models/Labels/Tapes/Dymo/LabelWriter_30252.php
index ed8074547b..8c3f050242 100644
--- a/app/Models/Labels/Tapes/Dymo/LabelWriter_30252.php
+++ b/app/Models/Labels/Tapes/Dymo/LabelWriter_30252.php
@@ -16,18 +16,45 @@ class LabelWriter_30252 extends LabelWriter
- public function getUnit() { return 'mm'; }
- public function getWidth() { return 96.52; }
- public function getSupportAssetTag() { return true; }
- public function getSupport1DBarcode() { return true; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 3; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return true; }
-
- public function preparePDF($pdf) {}
-
- public function write($pdf, $record) {
+ public function getUnit()
+ {
+ return 'mm';
+ }
+ public function getWidth()
+ {
+ return 96.52;
+ }
+ public function getSupportAssetTag()
+ {
+ return true;
+ }
+ public function getSupport1DBarcode()
+ {
+ return true;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 3;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
+
+ public function preparePDF($pdf)
+ {
+ }
+
+ public function write($pdf, $record)
+ {
$pa = $this->getPrintableArea();
$currentX = $pa->x1;
diff --git a/app/Models/Labels/Tapes/Generic/Continuous_53mm.php b/app/Models/Labels/Tapes/Generic/Continuous_53mm.php
index 4e06e2c96d..18b12fbc99 100644
--- a/app/Models/Labels/Tapes/Generic/Continuous_53mm.php
+++ b/app/Models/Labels/Tapes/Generic/Continuous_53mm.php
@@ -15,28 +15,30 @@ abstract class Continuous_53mm extends GenericTape
*
* Assumes tape is continuous, set to false and specify
* $spacing in concrete classfor die-cut labels
- *
*
- * @param float $height Height of the label in mm (default 60mm)
- * @param bool $continuous Whether the tape is continuous or pre-cut
- * @param float $spacing Spacing between labels for non-continuous tapes (in mm)
+ * @param float $height Height of the label in mm (default 60mm)
+ * @param bool $continuous Whether the tape is continuous or pre-cut
+ * @param float $spacing Spacing between labels for non-continuous tapes (in mm)
*/
- public function __construct($height = 60.0, $continuous = true, $spacing = 0.0) {
+ public function __construct($height = 60.0, $continuous = true, $spacing = 0.0)
+ {
parent::__construct(self::TAPE_WIDTH, $height, $continuous, $spacing);
$this->tapeHeight = $height;
}
- public function getBarcodeRatio() {
+ public function getBarcodeRatio()
+ {
return 0.9; // Barcode should use 90% of available width
}
/**
* Calculate the required height for the content
*
- * @param $record The record to calculate height for
+ * @param $record The record to calculate height for
* @return float The calculated height in mm
*/
- protected function calculateRequiredHeight($record) {
+ protected function calculateRequiredHeight($record)
+ {
$height = $this->marginTop + $this->marginBottom;
// Add title height if present
@@ -45,8 +47,9 @@ abstract class Continuous_53mm extends GenericTape
}
// Add barcode height if present
- if (($record->has('barcode2d') && $this->getSupport2DBarcode()) ||
- ($record->has('barcode') && $this->getSupport1DBarcode())) {
+ if (($record->has('barcode2d') && $this->getSupport2DBarcode())
+ || ($record->has('barcode') && $this->getSupport1DBarcode())
+ ) {
$pa = $this->getPrintableArea();
$usableWidth = $pa->w;
$barcodeSize = $usableWidth * $this->getBarcodeRatio();
@@ -71,31 +74,34 @@ abstract class Continuous_53mm extends GenericTape
/**
* Override the writeAll method to support dynamic page sizes for continuous tapes
*/
- public function writeAll($pdf, $data) {
+ public function writeAll($pdf, $data)
+ {
// Use auto-sizing for continuous tapes, fixed height for die-cut tapes
if ($this->continuous) {
- $data->each(function ($record, $index) use ($pdf) {
- // Calculate the required height for this record
- $requiredHeight = $this->calculateRequiredHeight($record);
+ $data->each(
+ function ($record, $index) use ($pdf) {
+ // Calculate the required height for this record
+ $requiredHeight = $this->calculateRequiredHeight($record);
- // Temporarily update the height property
- $originalHeight = $this->height;
- $this->height = $requiredHeight;
+ // Temporarily update the height property
+ $originalHeight = $this->height;
+ $this->height = $requiredHeight;
- // Add a new page with the calculated dimensions
- $pdf->AddPage(
- $this->getOrientation(),
- [$this->getWidth(), $requiredHeight],
- false, // Don't reset page number
- false // Don't reset object ID
- );
+ // Add a new page with the calculated dimensions
+ $pdf->AddPage(
+ $this->getOrientation(),
+ [$this->getWidth(), $requiredHeight],
+ false, // Don't reset page number
+ false // Don't reset object ID
+ );
- // Write the content
- $this->write($pdf, $record);
+ // Write the content
+ $this->write($pdf, $record);
- // Restore the original height
- $this->height = $originalHeight;
- });
+ // Restore the original height
+ $this->height = $originalHeight;
+ }
+ );
} else {
// Use the default implementation for non-continuous (die-cut) tapes
parent::writeAll($pdf, $data);
diff --git a/app/Models/Labels/Tapes/Generic/Continuous_53mm_A.php b/app/Models/Labels/Tapes/Generic/Continuous_53mm_A.php
index 632695ea1a..4f40f64627 100644
--- a/app/Models/Labels/Tapes/Generic/Continuous_53mm_A.php
+++ b/app/Models/Labels/Tapes/Generic/Continuous_53mm_A.php
@@ -5,19 +5,42 @@ namespace App\Models\Labels\Tapes\Generic;
class Continuous_53mm_A extends Continuous_53mm
{
- public function getUnit() { return 'mm'; }
- public function getSupportAssetTag() { return false; }
- public function getSupport1DBarcode() { return true; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 5; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return true; }
+ public function getUnit()
+ {
+ return 'mm';
+ }
+ public function getSupportAssetTag()
+ {
+ return false;
+ }
+ public function getSupport1DBarcode()
+ {
+ return true;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 5;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {
+ public function preparePDF($pdf)
+ {
$pdf->SetAutoPageBreak(false);
}
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getPrintableArea();
$currentX = $pa->x1;
diff --git a/app/Models/Labels/Tapes/Generic/Continuous_Landscape_0_59in.php b/app/Models/Labels/Tapes/Generic/Continuous_Landscape_0_59in.php
index 5efd88ff06..47856823bc 100644
--- a/app/Models/Labels/Tapes/Generic/Continuous_Landscape_0_59in.php
+++ b/app/Models/Labels/Tapes/Generic/Continuous_Landscape_0_59in.php
@@ -13,11 +13,12 @@ abstract class Continuous_Landscape_0_59in extends GenericTape
protected float $minHeight = 1;
/**
- * @param float $length Length of the label in inches (default 2.36in which is 60mm)
- * @param bool $continuous Whether the tape is continuous or pre-cut
- * @param float $spacing Spacing between labels for non-continuous tapes (in inches)
+ * @param float $length Length of the label in inches (default 2.36in which is 60mm)
+ * @param bool $continuous Whether the tape is continuous or pre-cut
+ * @param float $spacing Spacing between labels for non-continuous tapes (in inches)
*/
- public function __construct($length = 0.6, $continuous = true, $spacing = 0.0) {
+ public function __construct($length = 0.6, $continuous = true, $spacing = 0.0)
+ {
// Swap width and height for landscape orientation
// The height becomes the width, and the length becomes the height
parent::__construct($length, self::TAPE_WIDTH, $continuous, $spacing);
@@ -44,24 +45,27 @@ abstract class Continuous_Landscape_0_59in extends GenericTape
$this->tagSize = $baseFontSize * 0.8; // 80% of base font size
}
- public function getBarcodeRatio() {
+ public function getBarcodeRatio()
+ {
return 1.0; // Barcode should use 100% of available height
}
/**
* Calculate the required length for the content
*
- * @param $record The record to calculate length for
+ * @param $record The record to calculate length for
* @return float The calculated length in inches
*/
- protected function calculateRequiredLength($record) {
+ protected function calculateRequiredLength($record)
+ {
// Calculate length needed for barcode and fields side by side
$requiredLength = 0;
// Add barcode length if present
- if (($record->has('barcode2d') && $this->getSupport2DBarcode()) ||
- ($record->has('barcode') && $this->getSupport1DBarcode())) {
+ if (($record->has('barcode2d') && $this->getSupport2DBarcode())
+ || ($record->has('barcode') && $this->getSupport1DBarcode())
+ ) {
// Use full tape width for barcode size
$barcodeSize = self::TAPE_WIDTH;
$requiredLength += $barcodeSize + $this->barcodeMargin * 0.3; // Minimal margin
@@ -107,14 +111,15 @@ abstract class Continuous_Landscape_0_59in extends GenericTape
/**
* Calculate text width accurately using the PDF object
*
- * @param $pdf The PDF object
- * @param string $text The text to measure
- * @param string $font The font to use
- * @param string $style The font style
- * @param float $size The font size
+ * @param $pdf The PDF object
+ * @param string $text The text to measure
+ * @param string $font The font to use
+ * @param string $style The font style
+ * @param float $size The font size
* @return float The calculated width
*/
- protected function calculateTextWidth($pdf, $text, $font, $style, $size) {
+ protected function calculateTextWidth($pdf, $text, $font, $style, $size)
+ {
$originalFont = $pdf->getFontFamily();
$originalStyle = $pdf->getFontStyle();
$originalSize = $pdf->getFontSizePt();
@@ -131,37 +136,40 @@ abstract class Continuous_Landscape_0_59in extends GenericTape
/**
* Override the writeAll method to support dynamic page sizes for continuous tapes
*/
- public function writeAll($pdf, $data) {
+ public function writeAll($pdf, $data)
+ {
// Use auto-sizing for continuous tapes, fixed height for die-cut tapes
if ($this->continuous) {
- $data->each(function ($record, $index) use ($pdf) {
- // Calculate the required length by calling write with calculateOnly=true
- $requiredLength = $this->write($pdf, $record);
+ $data->each(
+ function ($record, $index) use ($pdf) {
+ // Calculate the required length by calling write with calculateOnly=true
+ $requiredLength = $this->write($pdf, $record);
- // If write didn't return a length (old implementation), fall back to calculateRequiredLength
- if ($requiredLength === null) {
- $requiredLength = $this->calculateRequiredLength($record);
- }
+ // If write didn't return a length (old implementation), fall back to calculateRequiredLength
+ if ($requiredLength === null) {
+ $requiredLength = $this->calculateRequiredLength($record);
+ }
- // Temporarily update the height property
- $originalHeight = $this->height;
- $this->height = self::TAPE_WIDTH; // Keep height fixed at tape width
+ // Temporarily update the height property
+ $originalHeight = $this->height;
+ $this->height = self::TAPE_WIDTH; // Keep height fixed at tape width
- // Add a new page with the calculated dimensions
- // Keep height fixed at TAPE_WIDTH, use calculated length for width
- $pdf->AddPage(
- $this->getOrientation(),
- [$requiredLength, self::TAPE_WIDTH],
- false, // Don't reset page number
- false // Don't reset object ID
- );
+ // Add a new page with the calculated dimensions
+ // Keep height fixed at TAPE_WIDTH, use calculated length for width
+ $pdf->AddPage(
+ $this->getOrientation(),
+ [$requiredLength, self::TAPE_WIDTH],
+ false, // Don't reset page number
+ false // Don't reset object ID
+ );
- // Write the content
- $this->write($pdf, $record);
+ // Write the content
+ $this->write($pdf, $record);
- // Restore the original height
- $this->height = $originalHeight;
- });
+ // Restore the original height
+ $this->height = $originalHeight;
+ }
+ );
} else {
// Use the default implementation for non-continuous (die-cut) tapes
parent::writeAll($pdf, $data);
diff --git a/app/Models/Labels/Tapes/Generic/Continuous_Landscape_0_59in_A.php b/app/Models/Labels/Tapes/Generic/Continuous_Landscape_0_59in_A.php
index 7c5774e17d..23325aa837 100644
--- a/app/Models/Labels/Tapes/Generic/Continuous_Landscape_0_59in_A.php
+++ b/app/Models/Labels/Tapes/Generic/Continuous_Landscape_0_59in_A.php
@@ -4,19 +4,42 @@ namespace App\Models\Labels\Tapes\Generic;
class Continuous_Landscape_0_59in_A extends Continuous_Landscape_0_59in
{
- public function getUnit() { return 'in'; }
- public function getSupportAssetTag() { return false; }
- public function getSupport1DBarcode() { return true; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 2; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return false; }
+ public function getUnit()
+ {
+ return 'in';
+ }
+ public function getSupportAssetTag()
+ {
+ return false;
+ }
+ public function getSupport1DBarcode()
+ {
+ return true;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 2;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return false;
+ }
- public function preparePDF($pdf) {
+ public function preparePDF($pdf)
+ {
$pdf->SetAutoPageBreak(false);
}
- public function write($pdf, $record, $calculateOnly = false) {
+ public function write($pdf, $record, $calculateOnly = false)
+ {
$pa = $this->getPrintableArea();
$currentX = $pa->x1;
diff --git a/app/Models/Labels/Tapes/Generic/GenericTape.php b/app/Models/Labels/Tapes/Generic/GenericTape.php
index 3825d54e2e..1c8426a79a 100644
--- a/app/Models/Labels/Tapes/Generic/GenericTape.php
+++ b/app/Models/Labels/Tapes/Generic/GenericTape.php
@@ -35,12 +35,13 @@ abstract class GenericTape extends Label
/**
* Constructor for generic tape
*
- * @param float $width Width of the tape in mm
- * @param float $height Height of the label in mm (for continuous tapes, this is the default height)
- * @param bool $continuous Whether the tape is continuous or pre-cut
- * @param float $spacing Spacing between labels for non-continuous tapes (in mm)
+ * @param float $width Width of the tape in mm
+ * @param float $height Height of the label in mm (for continuous tapes, this is the default height)
+ * @param bool $continuous Whether the tape is continuous or pre-cut
+ * @param float $spacing Spacing between labels for non-continuous tapes (in mm)
*/
- public function __construct(float $width, float $height, bool $continuous = true, float $spacing = 0.0) {
+ public function __construct(float $width, float $height, bool $continuous = true, float $spacing = 0.0)
+ {
$this->width = $width;
$this->height = $height;
$this->continuous = $continuous;
@@ -70,17 +71,38 @@ abstract class GenericTape extends Label
}
// Unit of measurement
- public function getUnit() { return 'mm'; }
+ public function getUnit()
+ {
+ return 'mm';
+ }
// Label dimensions
- public function getWidth() { return $this->width; }
- public function getHeight() { return $this->height; }
+ public function getWidth()
+ {
+ return $this->width;
+ }
+ public function getHeight()
+ {
+ return $this->height;
+ }
// Margins
- public function getMarginTop() { return $this->marginTop; }
- public function getMarginBottom() { return $this->marginBottom; }
- public function getMarginLeft() { return $this->marginLeft; }
- public function getMarginRight() { return $this->marginRight; }
+ public function getMarginTop()
+ {
+ return $this->marginTop;
+ }
+ public function getMarginBottom()
+ {
+ return $this->marginBottom;
+ }
+ public function getMarginLeft()
+ {
+ return $this->marginLeft;
+ }
+ public function getMarginRight()
+ {
+ return $this->marginRight;
+ }
/**
@@ -88,7 +110,8 @@ abstract class GenericTape extends Label
*
* @return bool
*/
- public function isContinuous() {
+ public function isContinuous()
+ {
return $this->continuous;
}
@@ -97,7 +120,8 @@ abstract class GenericTape extends Label
*
* @return float
*/
- public function getSpacing() {
+ public function getSpacing()
+ {
return $this->spacing;
}
}
\ No newline at end of file
diff --git a/app/Models/Labels/Tapes/Generic/Tape_53mm.php b/app/Models/Labels/Tapes/Generic/Tape_53mm.php
index fc46838d66..679380f221 100644
--- a/app/Models/Labels/Tapes/Generic/Tape_53mm.php
+++ b/app/Models/Labels/Tapes/Generic/Tape_53mm.php
@@ -12,11 +12,12 @@ abstract class Tape_53mm extends GenericTape
/**
* Constructor for 53mm tape
*
- * @param float $height Height of the label in mm (default 30mm)
- * @param bool $continuous Whether the tape is continuous or pre-cut
- * @param float $spacing Spacing between labels for non-continuous tapes (in mm)
+ * @param float $height Height of the label in mm (default 30mm)
+ * @param bool $continuous Whether the tape is continuous or pre-cut
+ * @param float $spacing Spacing between labels for non-continuous tapes (in mm)
*/
- public function __construct(float $height = 30.0, bool $continuous = true, float $spacing = 0.0) {
+ public function __construct(float $height = 30.0, bool $continuous = true, float $spacing = 0.0)
+ {
parent::__construct(self::TAPE_WIDTH, $height, $continuous, $spacing);
$this->tapeHeight = $height;
}
@@ -26,7 +27,8 @@ abstract class Tape_53mm extends GenericTape
*
* @return float
*/
- public function getBarcodeRatio() {
+ public function getBarcodeRatio()
+ {
return 0.9; // Barcode should use 90% of available width
}
}
\ No newline at end of file
diff --git a/app/Models/Labels/Tapes/Generic/Tape_53mm_A.php b/app/Models/Labels/Tapes/Generic/Tape_53mm_A.php
index 399efbe11c..8b7a79dda0 100644
--- a/app/Models/Labels/Tapes/Generic/Tape_53mm_A.php
+++ b/app/Models/Labels/Tapes/Generic/Tape_53mm_A.php
@@ -5,23 +5,47 @@ namespace App\Models\Labels\Tapes\Generic;
class Tape_53mm_A extends Tape_53mm
{
- public function __construct() {
+ public function __construct()
+ {
parent::__construct(40.0, true, 0.0);
}
- public function getUnit() { return 'mm'; }
- public function getSupportAssetTag() { return false; }
- public function getSupport1DBarcode() { return false; }
- public function getSupport2DBarcode() { return true; }
- public function getSupportFields() { return 5; }
- public function getSupportLogo() { return false; }
- public function getSupportTitle() { return true; }
+ public function getUnit()
+ {
+ return 'mm';
+ }
+ public function getSupportAssetTag()
+ {
+ return false;
+ }
+ public function getSupport1DBarcode()
+ {
+ return false;
+ }
+ public function getSupport2DBarcode()
+ {
+ return true;
+ }
+ public function getSupportFields()
+ {
+ return 5;
+ }
+ public function getSupportLogo()
+ {
+ return false;
+ }
+ public function getSupportTitle()
+ {
+ return true;
+ }
- public function preparePDF($pdf) {
+ public function preparePDF($pdf)
+ {
$pdf->SetAutoPageBreak(false);
}
- public function write($pdf, $record) {
+ public function write($pdf, $record)
+ {
$pa = $this->getPrintableArea();
$currentX = $pa->x1;
diff --git a/app/Models/Ldap.php b/app/Models/Ldap.php
index f71f926a93..e99ae07265 100644
--- a/app/Models/Ldap.php
+++ b/app/Models/Ldap.php
@@ -31,7 +31,7 @@ class Ldap extends Model
* Makes a connection to LDAP using the settings in Admin > Settings.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
* @return connection
*/
public static function connectToLdap()
@@ -81,10 +81,10 @@ class Ldap extends Model
* Binds/authenticates the user to LDAP, and returns their attributes.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
- * @param $username
- * @param $password
- * @param bool|false $user
+ * @since [v3.0]
+ * @param $username
+ * @param $password
+ * @param bool|false $user
* @return bool true if the username and/or password provided are valid
* false if the username and/or password provided are invalid
* array of ldap_attributes if $user is true
@@ -160,8 +160,8 @@ class Ldap extends Model
* Here we also return a better error if the app key is donked.
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
- * @param bool|false $user
+ * @since [v3.0]
+ * @param bool|false $user
* @return bool true if the username and/or password provided are valid
* false if the username and/or password provided are invalid
*/
@@ -169,37 +169,37 @@ class Ldap extends Model
{
$ldap_username = Setting::getSettings()->ldap_uname;
- if ( $ldap_username ) {
- // Lets return some nicer messages for users who donked their app key, and disable LDAP
- try {
- $ldap_pass = Crypt::decrypt(Setting::getSettings()->ldap_pword);
- } catch (Exception $e) {
- throw new Exception('Your app key has changed! Could not decrypt LDAP password using your current app key, so LDAP authentication has been disabled. Login with a local account, update the LDAP password and re-enable it in Admin > Settings.');
- }
-
- if (! $ldapbind = @ldap_bind($connection, $ldap_username, $ldap_pass)) {
- throw new Exception('Could not bind to LDAP: '.ldap_error($connection));
- }
- // TODO - this just "falls off the end" but the function states that it should return true or false
- // unfortunately, one of the use cases for this function is wrong and *needs* for that failure mode to fire
- // so I don't want to fix this right now.
- // this method MODIFIES STATE on the passed-in $connection and just returns true or false (or, in this case, undefined)
- // at the next refactor, this should be appropriately modified to be more consistent.
- } else {
- // LDAP should also work with anonymous bind (no dn, no password available)
- if (! $ldapbind = @ldap_bind($connection )) {
- throw new Exception('Could not bind to LDAP: '.ldap_error($connection));
- }
- }
- }
+ if ($ldap_username ) {
+ // Lets return some nicer messages for users who donked their app key, and disable LDAP
+ try {
+ $ldap_pass = Crypt::decrypt(Setting::getSettings()->ldap_pword);
+ } catch (Exception $e) {
+ throw new Exception('Your app key has changed! Could not decrypt LDAP password using your current app key, so LDAP authentication has been disabled. Login with a local account, update the LDAP password and re-enable it in Admin > Settings.');
+ }
+
+ if (! $ldapbind = @ldap_bind($connection, $ldap_username, $ldap_pass)) {
+ throw new Exception('Could not bind to LDAP: '.ldap_error($connection));
+ }
+ // TODO - this just "falls off the end" but the function states that it should return true or false
+ // unfortunately, one of the use cases for this function is wrong and *needs* for that failure mode to fire
+ // so I don't want to fix this right now.
+ // this method MODIFIES STATE on the passed-in $connection and just returns true or false (or, in this case, undefined)
+ // at the next refactor, this should be appropriately modified to be more consistent.
+ } else {
+ // LDAP should also work with anonymous bind (no dn, no password available)
+ if (! $ldapbind = @ldap_bind($connection)) {
+ throw new Exception('Could not bind to LDAP: '.ldap_error($connection));
+ }
+ }
+ }
/**
* Parse and map LDAP attributes based on settings
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
+ * @since [v3.0]
*
- * @param $ldapatttibutes
+ * @param $ldapatttibutes
* @return array|bool
*/
public static function parseAndMapLdapAttributes($ldapattributes)
@@ -238,8 +238,8 @@ class Ldap extends Model
* Create user from LDAP attributes
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
- * @param $ldapatttibutes
+ * @since [v3.0]
+ * @param $ldapatttibutes
* @return User | bool
*/
public static function createUserFromLdap($ldapatttibutes, $password)
@@ -279,11 +279,11 @@ class Ldap extends Model
* Searches LDAP
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
- * @param $base_dn
- * @param $count
- * @param $filter
- * @param $attributes
+ * @since [v3.0]
+ * @param $base_dn
+ * @param $count
+ * @param $filter
+ * @param $attributes
* @return array|bool
*/
public static function findLdapUsers($base_dn = null, $count = -1, $filter = null, $attributes = [])
@@ -331,7 +331,7 @@ class Ldap extends Model
$errmsg = null;
$referrals = null;
$controls = [];
- ldap_parse_result($ldapconn, $search_results, $errcode , $matcheddn , $errmsg , $referrals, $controls);
+ ldap_parse_result($ldapconn, $search_results, $errcode, $matcheddn, $errmsg, $referrals, $controls);
if (isset($controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'])) {
// You need to pass the cookie from the last call to the next one
$cookie = $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'];
diff --git a/app/Models/License.php b/app/Models/License.php
index ec38b69b9a..a40728a832 100755
--- a/app/Models/License.php
+++ b/app/Models/License.php
@@ -123,32 +123,36 @@ class License extends Depreciable
* Update seat counts when the license is updated
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
*/
public static function boot()
{
parent::boot();
// We need to listen for created for the initial setup so that we have a license ID.
- static::created(function ($license) {
- $newSeatCount = $license->getAttributes()['seats'];
+ static::created(
+ function ($license) {
+ $newSeatCount = $license->getAttributes()['seats'];
- return static::adjustSeatCount($license, 0, $newSeatCount);
- });
+ return static::adjustSeatCount($license, 0, $newSeatCount);
+ }
+ );
// However, we listen for updating to be able to prevent the edit if we cannot delete enough seats.
- static::updating(function ($license) {
- $newSeatCount = $license->getAttributes()['seats'];
- //$oldSeatCount = isset($license->getOriginal()['seats']) ? $license->getOriginal()['seats'] : 0;
- /*
- That previous method *did* mostly work, but if you ever managed to get your $license->seats value out of whack
- with your actual count of license_seats *records*, you would never manage to get back 'into whack'.
- The below method actually grabs a count of existing license_seats records, so it will be more accurate.
- This means that if your license_seats are out of whack, you can change the quantity and hit 'save' and it
- will manage to 'true up' and make your counts line up correctly.
- */
- $oldSeatCount = $license->license_seats_count;
-
- return static::adjustSeatCount($license, $oldSeatCount, $newSeatCount);
- });
+ static::updating(
+ function ($license) {
+ $newSeatCount = $license->getAttributes()['seats'];
+ //$oldSeatCount = isset($license->getOriginal()['seats']) ? $license->getOriginal()['seats'] : 0;
+ /*
+ That previous method *did* mostly work, but if you ever managed to get your $license->seats value out of whack
+ with your actual count of license_seats *records*, you would never manage to get back 'into whack'.
+ The below method actually grabs a count of existing license_seats records, so it will be more accurate.
+ This means that if your license_seats are out of whack, you can change the quantity and hit 'save' and it
+ will manage to 'true up' and make your counts line up correctly.
+ */
+ $oldSeatCount = $license->license_seats_count;
+
+ return static::adjustSeatCount($license, $oldSeatCount, $newSeatCount);
+ }
+ );
}
public function prepareLimitChangeRule($parameters, $field)
@@ -163,7 +167,7 @@ class License extends Depreciable
* Balance seat counts
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public static function adjustSeatCount($license, $oldSeats, $newSeats)
@@ -210,11 +214,15 @@ class License extends Depreciable
}
//Chunk and use DB transactions to prevent timeouts.
- collect($licenseInsert)->chunk(1000)->each(function ($chunk) {
- DB::transaction(function () use ($chunk) {
- LicenseSeat::insert($chunk->toArray());
- });
- });
+ collect($licenseInsert)->chunk(1000)->each(
+ function ($chunk) {
+ DB::transaction(
+ function () use ($chunk) {
+ LicenseSeat::insert($chunk->toArray());
+ }
+ );
+ }
+ );
// On initial create, we shouldn't log the addition of seats.
if ($license->id) {
@@ -235,7 +243,7 @@ class License extends Depreciable
* Sets the attribute for whether or not the license is maintained
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return mixed
*/
public function setMaintainedAttribute($value)
@@ -247,7 +255,7 @@ class License extends Depreciable
* Sets the reassignable attribute
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return mixed
*/
public function setReassignableAttribute($value)
@@ -259,7 +267,7 @@ class License extends Depreciable
* Sets expiration date attribute
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return mixed
*/
public function setExpirationDateAttribute($value)
@@ -276,7 +284,7 @@ class License extends Depreciable
* Sets termination date attribute
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return mixed
*/
public function setTerminationDateAttribute($value)
@@ -292,10 +300,11 @@ class License extends Depreciable
* Sets free_seat_count attribute
*
* @author G. Martinez
- * @since [v6.3]
+ * @since [v6.3]
* @return mixed
*/
- public function getFreeSeatCountAttribute(){
+ public function getFreeSeatCountAttribute()
+ {
return $this->attributes['free_seat_count'] = $this->remaincount();
}
@@ -303,7 +312,7 @@ class License extends Depreciable
* Establishes the license -> company relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function company()
@@ -315,7 +324,7 @@ class License extends Depreciable
* Establishes the license -> category relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v4.4.0]
+ * @since [v4.4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function category()
@@ -327,7 +336,7 @@ class License extends Depreciable
* Establishes the license -> manufacturer relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function manufacturer()
@@ -339,7 +348,7 @@ class License extends Depreciable
* Determine whether the user should be emailed on checkin/checkout
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return bool
*/
public function checkin_email()
@@ -354,7 +363,7 @@ class License extends Depreciable
* Determine whether the user should be required to accept the license
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return bool
*/
public function requireAcceptance()
@@ -371,12 +380,12 @@ class License extends Depreciable
* checks for a settings level EULA
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
* @return string | false
*/
public function getEula()
{
- if ($this->category){
+ if ($this->category) {
if ($this->category->eula_text) {
return Helper::parseEscapedMarkedown($this->category->eula_text);
} elseif ($this->category->use_default_eula == '1') {
@@ -392,7 +401,7 @@ class License extends Depreciable
* Establishes the license -> assigned user relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assignedusers()
@@ -404,7 +413,7 @@ class License extends Depreciable
* Establishes the license -> action logs relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assetlog()
@@ -420,7 +429,7 @@ class License extends Depreciable
* Establishes the license -> admin user relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function adminuser()
@@ -434,7 +443,7 @@ class License extends Depreciable
* @todo this can probably be refactored at some point. We don't need counting methods.
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return int
*/
public static function assetcount()
@@ -450,7 +459,7 @@ class License extends Depreciable
* @todo this can also probably be refactored at some point.
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function totalSeatsByLicenseID()
@@ -467,7 +476,7 @@ class License extends Depreciable
* Otherwise calling "count()" on each model results in n+1 sadness.
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function licenseSeatsRelation()
@@ -479,7 +488,7 @@ class License extends Depreciable
* Sets the license seat count attribute
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return int
*/
public function getLicenseSeatsCountAttribute()
@@ -495,7 +504,7 @@ class License extends Depreciable
* Returns the number of total available seats across all licenses
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return int
*/
public static function availassetcount()
@@ -509,7 +518,7 @@ class License extends Depreciable
* Returns the available seats remaining
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return int
*/
@@ -517,7 +526,7 @@ class License extends Depreciable
* Returns the number of total available seats for this license
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function availCount()
@@ -532,7 +541,7 @@ class License extends Depreciable
* Sets the available seats attribute
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return mixed
*/
public function getAvailSeatsCountAttribute()
@@ -548,22 +557,24 @@ class License extends Depreciable
* Retuns the number of assigned seats for this asset
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assignedCount()
{
- return $this->licenseSeatsRelation()->where(function ($query) {
- $query->whereNotNull('assigned_to')
- ->orWhereNotNull('asset_id');
- });
+ return $this->licenseSeatsRelation()->where(
+ function ($query) {
+ $query->whereNotNull('assigned_to')
+ ->orWhereNotNull('asset_id');
+ }
+ );
}
/**
* Sets the assigned seats attribute
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return int
*/
public function getAssignedSeatsCountAttribute()
@@ -579,7 +590,7 @@ class License extends Depreciable
* Calculates the number of remaining seats
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return int
*/
public function remaincount()
@@ -595,7 +606,7 @@ class License extends Depreciable
* Returns the total number of seats for this license
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return int
*/
public function totalcount()
@@ -611,7 +622,7 @@ class License extends Depreciable
* Establishes the license -> seats relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function licenseseats()
@@ -623,7 +634,7 @@ class License extends Depreciable
* Establishes the license -> supplier relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function supplier()
@@ -637,17 +648,19 @@ class License extends Depreciable
* the API to populate next_seat
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return mixed
*/
public function freeSeat()
{
return $this->licenseseats()
->whereNull('deleted_at')
- ->where(function ($query) {
- $query->whereNull('assigned_to')
- ->whereNull('asset_id');
- })
+ ->where(
+ function ($query) {
+ $query->whereNull('assigned_to')
+ ->whereNull('asset_id');
+ }
+ )
->orderBy('id', 'asc')
->first();
}
@@ -657,7 +670,7 @@ class License extends Depreciable
* Establishes the license -> free seats relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function freeSeats()
@@ -671,7 +684,7 @@ class License extends Depreciable
* @todo should refactor. I don't like get() in model methods
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public static function getExpiringLicenses($days = 60)
@@ -689,8 +702,8 @@ class License extends Depreciable
/**
* Query builder scope to order on manufacturer
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -703,8 +716,8 @@ class License extends Depreciable
/**
* Query builder scope to order on supplier
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -717,8 +730,8 @@ class License extends Depreciable
/**
* Query builder scope to order on company
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
diff --git a/app/Models/LicenseSeat.php b/app/Models/LicenseSeat.php
index 2ca67839c6..52cbd9be5a 100755
--- a/app/Models/LicenseSeat.php
+++ b/app/Models/LicenseSeat.php
@@ -44,7 +44,7 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild
* Determine whether the user should be required to accept the license
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return bool
*/
public function requireAcceptance()
@@ -64,7 +64,7 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild
* Establishes the seat -> license relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function license()
@@ -76,7 +76,7 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild
* Establishes the seat -> assignee relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function user()
@@ -88,7 +88,7 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild
* Establishes the seat -> asset relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function asset()
@@ -101,7 +101,7 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild
* or asset its assigned to
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return string
*/
public function location()
@@ -118,8 +118,8 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild
/**
* Query builder scope to order on department
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -135,13 +135,16 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild
public function scopeByAssigned($query)
{
- return $query->where(function ($query) {
- $query->whereNotNull('assigned_to')
- ->orWhere(function($query)
- {
- $query->whereNotNull('asset_id');
- });
- });
+ return $query->where(
+ function ($query) {
+ $query->whereNotNull('assigned_to')
+ ->orWhere(
+ function ($query) {
+ $query->whereNotNull('asset_id');
+ }
+ );
+ }
+ );
}
diff --git a/app/Models/Location.php b/app/Models/Location.php
index 80f28de7a7..64187082d3 100755
--- a/app/Models/Location.php
+++ b/app/Models/Location.php
@@ -111,7 +111,7 @@ class Location extends SnipeModel
* it can be deleted. It's tempting to load those here, but that increases the query load considerably.
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return bool
*/
public function isDeletable()
@@ -129,7 +129,7 @@ class Location extends SnipeModel
* Establishes the user -> location relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function users()
@@ -152,17 +152,19 @@ class Location extends SnipeModel
* Find assets with this location as their location_id
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assets()
{
return $this->hasMany(\App\Models\Asset::class, 'location_id')
- ->whereHas('assetstatus', function ($query) {
- $query->where('status_labels.deployable', '=', 1)
+ ->whereHas(
+ 'assetstatus', function ($query) {
+ $query->where('status_labels.deployable', '=', 1)
->orWhere('status_labels.pending', '=', 1)
->orWhere('status_labels.archived', '=', 0);
- });
+ }
+ );
}
@@ -170,7 +172,7 @@ class Location extends SnipeModel
* Establishes the asset -> rtd_location relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function rtd_assets()
@@ -190,7 +192,7 @@ class Location extends SnipeModel
* Establishes the consumable -> location relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function consumables()
@@ -202,7 +204,7 @@ class Location extends SnipeModel
* Establishes the component -> location relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function components()
@@ -214,7 +216,7 @@ class Location extends SnipeModel
* Establishes the component -> accessory relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function accessories()
@@ -226,7 +228,7 @@ class Location extends SnipeModel
* Find the parent of a location
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function parent()
@@ -236,12 +238,12 @@ class Location extends SnipeModel
}
/**
- * Establishes the locations -> company relationship
- *
- * @author [T. Regnery] [<[email protected]>]
- * @since [v7.0]
- * @return \Illuminate\Database\Eloquent\Relations\Relation
- */
+ * Establishes the locations -> company relationship
+ *
+ * @author [T. Regnery] [<[email protected]>]
+ * @since [v7.0]
+ * @return \Illuminate\Database\Eloquent\Relations\Relation
+ */
public function company()
{
return $this->belongsTo(\App\Models\Company::class, 'company_id');
@@ -251,7 +253,7 @@ class Location extends SnipeModel
* Find the manager of a location
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function manager()
@@ -264,7 +266,7 @@ class Location extends SnipeModel
* Find children of a location
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function children()
@@ -277,7 +279,7 @@ class Location extends SnipeModel
* Establishes the asset -> location assignment relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assignedAssets()
@@ -289,7 +291,7 @@ class Location extends SnipeModel
* Establishes the accessory -> location assignment relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assignedAccessories()
@@ -306,8 +308,8 @@ class Location extends SnipeModel
/**
* Query builder scope to order on parent
*
- * @param Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return Illuminate\Database\Query\Builder Modified query builder
*/
@@ -335,8 +337,8 @@ class Location extends SnipeModel
/**
* Query builder scope to order on parent
*
- * @param Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return Illuminate\Database\Query\Builder Modified query builder
*/
@@ -349,8 +351,8 @@ class Location extends SnipeModel
/**
* Query builder scope to order on manager name
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -359,14 +361,14 @@ class Location extends SnipeModel
return $query->leftJoin('users as location_user', 'locations.manager_id', '=', 'location_user.id')->orderBy('location_user.first_name', $order)->orderBy('location_user.last_name', $order);
}
- /**
- * Query builder scope to order on company
- *
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
- *
- * @return \Illuminate\Database\Query\Builder Modified query builder
- */
+ /**
+ * Query builder scope to order on company
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
public function scopeOrderCompany($query, $order)
{
return $query->leftJoin('companies as company_sort', 'locations.company_id', '=', 'company_sort.id')->orderBy('company_sort.name', $order);
diff --git a/app/Models/Loggable.php b/app/Models/Loggable.php
index 54aeac5a44..f912d15927 100644
--- a/app/Models/Loggable.php
+++ b/app/Models/Loggable.php
@@ -15,8 +15,8 @@ trait Loggable
public ?bool $imported = false;
/**
- * @author Daniel Meltzer <[email protected]>
- * @since [v3.4]
+ * @author Daniel Meltzer <[email protected]>
+ * @since [v3.4]
* @return \App\Models\Actionlog
*/
public function log()
@@ -30,8 +30,8 @@ trait Loggable
}
/**
- * @author Daniel Meltzer <[email protected]>
- * @since [v3.4]
+ * @author Daniel Meltzer <[email protected]>
+ * @since [v3.4]
* @return \App\Models\Actionlog
*/
public function logCheckout($note, $target, $action_date = null, $originalValues = [])
@@ -108,7 +108,7 @@ trait Loggable
// NOTE - if the attribute exists in $originalValues, but *not* in ->getAttributes(), it isn't added to $changed
}
- if (!empty($changed)){
+ if (!empty($changed)) {
$log->log_meta = json_encode($changed);
}
@@ -135,8 +135,8 @@ trait Loggable
}
/**
- * @author Daniel Meltzer <[email protected]>
- * @since [v3.4]
+ * @author Daniel Meltzer <[email protected]>
+ * @since [v3.4]
* @return \App\Models\Actionlog
*/
public function logCheckin($target, $note, $action_date = null, $originalValues = [])
@@ -145,7 +145,7 @@ trait Loggable
$fields_array = [];
- if($target != null){
+ if($target != null) {
$log->target_type = get_class($target);
$log->target_id = $target->id;
@@ -205,7 +205,7 @@ trait Loggable
}
}
- if (!empty($changed)){
+ if (!empty($changed)) {
$log->log_meta = json_encode($changed);
}
@@ -215,8 +215,8 @@ trait Loggable
}
/**
- * @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @author A. Gianotto <[email protected]>
+ * @since [v4.0]
* @return \App\Models\Actionlog
*/
public function logAudit($note, $location_id, $filename = null, $originalValues = [])
@@ -249,7 +249,7 @@ trait Loggable
}
}
- if (!empty($changed)){
+ if (!empty($changed)) {
$log->log_meta = json_encode($changed);
}
@@ -276,7 +276,7 @@ trait Loggable
'location' => ($location) ? $location->name : '',
'note' => $note,
];
- if(Setting::getSettings()->webhook_selected === 'microsoft' && Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')){
+ if(Setting::getSettings()->webhook_selected === 'microsoft' && Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) {
$message = AuditNotification::toMicrosoftTeams($params);
$notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint);
$notification->success()->sendMessage($message[0], $message[1]);
@@ -289,8 +289,8 @@ trait Loggable
}
/**
- * @author Daniel Meltzer <[email protected]>
- * @since [v3.5]
+ * @author Daniel Meltzer <[email protected]>
+ * @since [v3.5]
* @return \App\Models\Actionlog
*/
public function logCreate($note = null)
@@ -318,8 +318,8 @@ trait Loggable
}
/**
- * @author Daniel Meltzer <[email protected]>
- * @since [v3.4]
+ * @author Daniel Meltzer <[email protected]>
+ * @since [v3.4]
* @return \App\Models\Actionlog
*/
public function logUpload($filename, $note)
@@ -350,7 +350,7 @@ trait Loggable
* Returns the latest acceptance ActionLog that contains a signature
* from $user or null if there is none
*
- * @param User $user
+ * @param User $user
* @return null|Actionlog
**/
public function getLatestSignedAcceptance(User $user)
diff --git a/app/Models/PredefinedKit.php b/app/Models/PredefinedKit.php
index 36790a1fc7..2d0c87066e 100644
--- a/app/Models/PredefinedKit.php
+++ b/app/Models/PredefinedKit.php
@@ -11,8 +11,8 @@ use Watson\Validating\ValidatingTrait;
/**
* Model for predefined kits.
*
- * @author [D. Minaev.] [<[email protected]>]
- * @version v1.0
+ * @author [D. Minaev.] [<[email protected]>]
+ * @version v1.0
*/
class PredefinedKit extends SnipeModel
{
@@ -39,8 +39,9 @@ class PredefinedKit extends SnipeModel
/**
* this rules use in edit an attached asset model form
* see PredefinedKit::_makeRuleHelper function for details
- * @param int $model_id
- * @param bool $new = true if append a new element to kit
+ *
+ * @param int $model_id
+ * @param bool $new = true if append a new element to kit
*/
public function makeModelRules($model_id, $new = false)
{
@@ -50,8 +51,9 @@ class PredefinedKit extends SnipeModel
/**
* this rules use in edit an attached license form
* see PredefinedKit::_makeRuleHelper function for details
- * @param int $license_id
- * @param bool $new = true if append a new element to kit
+ *
+ * @param int $license_id
+ * @param bool $new = true if append a new element to kit
*/
public function makeLicenseRules($license_id, $new = false)
{
@@ -61,8 +63,9 @@ class PredefinedKit extends SnipeModel
/**
* this rules use in edit an attached accessory form
* see PredefinedKit::_makeRuleHelper function for details
- * @param int $accessoriy_id
- * @param bool $new = true if append a new element to kit
+ *
+ * @param int $accessoriy_id
+ * @param bool $new = true if append a new element to kit
*/
public function makeAccessoryRules($accessory_id, $new = false)
{
@@ -72,8 +75,9 @@ class PredefinedKit extends SnipeModel
/**
* this rules use in edit an attached consumable form
* see PredefinedKit::_makeRuleHelper function for details
- * @param int $consumable_id
- * @param bool $new = true if append a new element to kit
+ *
+ * @param int $consumable_id
+ * @param bool $new = true if append a new element to kit
*/
public function makeConsumableRules($consumable_id, $new = false)
{
@@ -86,11 +90,12 @@ class PredefinedKit extends SnipeModel
* uniqueness of the record in table for this kit
* existence of record in table
* and simple types check
- * @param string $table element table name
- * @param string $pivot_table kit+element table name
- * @param string $pivot_elem_key element key name inside pivot table
- * @param int $element_id
- * @param bool $new = true if append a new element to kit
+ *
+ * @param string $table element table name
+ * @param string $pivot_table kit+element table name
+ * @param string $pivot_elem_key element key name inside pivot table
+ * @param int $element_id
+ * @param bool $new = true if append a new element to kit
* @return array
*/
protected function _makeRuleHelper($table, $pivot_table, $pivot_elem_key, $element_id, $new)
@@ -144,6 +149,7 @@ class PredefinedKit extends SnipeModel
/**
* Establishes the kits -> models relationship
+ *
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function models()
@@ -158,6 +164,7 @@ class PredefinedKit extends SnipeModel
/**
* Establishes the kits -> licenses relationship
+ *
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function licenses()
@@ -167,6 +174,7 @@ class PredefinedKit extends SnipeModel
/**
* Establishes the kits -> licenses relationship
+ *
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function consumables()
@@ -176,6 +184,7 @@ class PredefinedKit extends SnipeModel
/**
* Establishes the kits -> licenses relationship
+ *
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function accessories()
diff --git a/app/Models/Recipients/AdminRecipient.php b/app/Models/Recipients/AdminRecipient.php
index 90e39d4ee5..f74997abd2 100644
--- a/app/Models/Recipients/AdminRecipient.php
+++ b/app/Models/Recipients/AdminRecipient.php
@@ -14,7 +14,8 @@ class AdminRecipient extends Recipient
$this->email = trim($settings->admin_cc_email);
}
- public function getEmail(){
+ public function getEmail()
+ {
return $this->email;
}
}
diff --git a/app/Models/ReportTemplate.php b/app/Models/ReportTemplate.php
index cdd05b6f50..452bd029d7 100644
--- a/app/Models/ReportTemplate.php
+++ b/app/Models/ReportTemplate.php
@@ -39,16 +39,17 @@ class ReportTemplate extends Model
protected static function booted()
{
// Scope to current user
- static::addGlobalScope('current_user', function (Builder $builder) {
- if (auth()->check()) {
- $builder->where('created_by', auth()->id());
+ static::addGlobalScope(
+ 'current_user', function (Builder $builder) {
+ if (auth()->check()) {
+ $builder->where('created_by', auth()->id());
+ }
}
- });
+ );
}
/**
* Establishes the report template -> creator relationship.
- *
*/
public function creator(): BelongsTo
{
@@ -60,7 +61,6 @@ class ReportTemplate extends Model
*
* @param string $fieldName
* @param string $fallbackValue The value to return if the report template is not saved yet.
- *
*/
public function checkmarkValue(string $fieldName, string $fallbackValue = '1'): string
{
@@ -83,9 +83,8 @@ class ReportTemplate extends Model
* Get the value of a radio field for the given field name.
*
* @param string $fieldName
- * @param string $value The value to check against.
- * @param bool $isDefault Whether the radio input being checked is the default.
- *
+ * @param string $value The value to check against.
+ * @param bool $isDefault Whether the radio input being checked is the default.
*/
public function radioValue(string $fieldName, string $value, bool $isDefault = false): bool
{
@@ -109,11 +108,10 @@ class ReportTemplate extends Model
/**
* Get the value of a select field for the given field name.
*
- * @param string $fieldName
- * @param string|null $model The Eloquent model to check against.
+ * @param string $fieldName
+ * @param string|null $model The Eloquent model to check against.
*
* @return mixed|null
- *
*/
public function selectValue(string $fieldName, string $model = null)
{
@@ -146,11 +144,10 @@ class ReportTemplate extends Model
/**
* Get the values of a multi-select field for the given field name.
*
- * @param string $fieldName
- * @param string|null $model The Eloquent model to check against.
+ * @param string $fieldName
+ * @param string|null $model The Eloquent model to check against.
*
* @return iterable
- *
*/
public function selectValues(string $fieldName, string $model = null): iterable
{
@@ -178,8 +175,8 @@ class ReportTemplate extends Model
/**
* Get the value of a text field for the given field name.
*
- * @param string $fieldName
- * @param string|null $fallbackValue
+ * @param string $fieldName
+ * @param string|null $fallbackValue
*
* @return string
*/
diff --git a/app/Models/Requestable.php b/app/Models/Requestable.php
index 4dead82bb3..016c1e1692 100644
--- a/app/Models/Requestable.php
+++ b/app/Models/Requestable.php
@@ -21,9 +21,11 @@ trait Requestable
public function scopeRequestedBy($query, User $user)
{
- return $query->whereHas('requests', function ($query) use ($user) {
- $query->where('user_id', $user->id);
- });
+ return $query->whereHas(
+ 'requests', function ($query) use ($user) {
+ $query->where('user_id', $user->id);
+ }
+ );
}
public function request($qty = 1)
@@ -40,7 +42,7 @@ trait Requestable
public function cancelRequest($user_id = null)
{
- if (!$user_id){
+ if (!$user_id) {
$user_id = auth()->id();
}
diff --git a/app/Models/SCIMUser.php b/app/Models/SCIMUser.php
index fcf34c0d5d..f261fea8b6 100644
--- a/app/Models/SCIMUser.php
+++ b/app/Models/SCIMUser.php
@@ -8,7 +8,8 @@ class SCIMUser extends User
protected $throwValidationExceptions = true; // we want model-level validation to fully THROW, not just return false
- public function __construct(array $attributes = []) {
+ public function __construct(array $attributes = [])
+ {
$attributes['password'] = $this->noPassword();
parent::__construct($attributes);
}
diff --git a/app/Models/Setting.php b/app/Models/Setting.php
index 73fcada1e6..4b96230027 100755
--- a/app/Models/Setting.php
+++ b/app/Models/Setting.php
@@ -25,6 +25,7 @@ class Setting extends Model
/**
* The cache property so that multiple invocations of this will only load the Settings record from disk only once
+ *
* @var self
*/
public static ?self $_cache = null;
@@ -306,7 +307,8 @@ class Setting extends Model
*/
public static function getLdapSettings(): Collection
{
- $ldapSettings = self::select([
+ $ldapSettings = self::select(
+ [
'ldap_enabled',
'ldap_server',
'ldap_uname',
@@ -337,7 +339,8 @@ class Setting extends Model
'ldap_manager',
'ldap_country',
'ldap_location',
- ])->first()->getAttributes();
+ ]
+ )->first()->getAttributes();
return collect($ldapSettings);
}
diff --git a/app/Models/SnipeSCIMConfig.php b/app/Models/SnipeSCIMConfig.php
index f17b5cfb61..b7b789bf3d 100644
--- a/app/Models/SnipeSCIMConfig.php
+++ b/app/Models/SnipeSCIMConfig.php
@@ -64,7 +64,7 @@ class SnipeSCIMConfig extends \ArieTimmerman\Laravel\SCIMServer\SCIMConfig
//eager loading
'withRelations' => [],
'map_unmapped' => false,
-// 'unmapped_namespace' => 'urn:ietf:params:scim:schemas:laravel:unmapped',
+ // 'unmapped_namespace' => 'urn:ietf:params:scim:schemas:laravel:unmapped',
'description' => 'User Account',
// Map a SCIM attribute to an attribute of the object.
diff --git a/app/Models/Statuslabel.php b/app/Models/Statuslabel.php
index c1bcc3042d..bd981d867a 100755
--- a/app/Models/Statuslabel.php
+++ b/app/Models/Statuslabel.php
@@ -56,7 +56,7 @@ class Statuslabel extends SnipeModel
* Establishes the status label -> assets relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assets()
@@ -73,7 +73,7 @@ class Statuslabel extends SnipeModel
* Gets the status label type
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return string
*/
public function getStatuslabelType()
@@ -97,8 +97,8 @@ class Statuslabel extends SnipeModel
public function scopePending()
{
return $this->where('pending', '=', 1)
- ->where('archived', '=', 0)
- ->where('deployable', '=', 0);
+ ->where('archived', '=', 0)
+ ->where('deployable', '=', 0);
}
/**
@@ -141,7 +141,7 @@ class Statuslabel extends SnipeModel
* Helper function to determine type attributes
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return string
*/
public static function getStatuslabelTypesForDB($type)
diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php
index 0166229f89..8d080846d9 100755
--- a/app/Models/Supplier.php
+++ b/app/Models/Supplier.php
@@ -71,7 +71,7 @@ class Supplier extends SnipeModel
* Otherwise calling "count()" on each model results in n+1.
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assetsRelation()
@@ -84,7 +84,7 @@ class Supplier extends SnipeModel
* Establishes the supplier -> assets relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assets()
@@ -96,7 +96,7 @@ class Supplier extends SnipeModel
* Establishes the supplier -> accessories relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function accessories()
@@ -108,7 +108,7 @@ class Supplier extends SnipeModel
* Establishes the supplier -> component relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v6.1.1]
+ * @since [v6.1.1]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function components()
@@ -120,7 +120,7 @@ class Supplier extends SnipeModel
* Establishes the supplier -> component relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v6.1.1]
+ * @since [v6.1.1]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function consumables()
@@ -144,7 +144,7 @@ class Supplier extends SnipeModel
* Establishes the supplier -> asset maintenances relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function asset_maintenances()
@@ -156,7 +156,7 @@ class Supplier extends SnipeModel
* Return the number of assets by supplier
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return int
*/
public function num_assets()
@@ -172,7 +172,7 @@ class Supplier extends SnipeModel
* Establishes the supplier -> license relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function licenses()
@@ -184,7 +184,7 @@ class Supplier extends SnipeModel
* Return the number of licenses by supplier
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return int
*/
public function num_licenses()
@@ -198,7 +198,7 @@ class Supplier extends SnipeModel
* @todo this should be handled via validation, no?
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function addhttp($url)
diff --git a/app/Models/Traits/Acceptable.php b/app/Models/Traits/Acceptable.php
index f0d1442ed3..6621cdb4fb 100644
--- a/app/Models/Traits/Acceptable.php
+++ b/app/Models/Traits/Acceptable.php
@@ -14,8 +14,8 @@ trait Acceptable
/**
* Run after the checkout acceptance was accepted by the user
*
- * @param User $acceptedBy
- * @param string $signature
+ * @param User $acceptedBy
+ * @param string $signature
*/
public function acceptedCheckout(User $acceptedBy, $signature, $filename = null)
{
@@ -25,8 +25,8 @@ trait Acceptable
/**
* Run after the checkout acceptance was declined by the user
*
- * @param User $acceptedBy
- * @param string $signature
+ * @param User $acceptedBy
+ * @param string $signature
*/
public function declinedCheckout(User $declinedBy, $signature)
{
diff --git a/app/Models/Traits/HasUploads.php b/app/Models/Traits/HasUploads.php
index da94e0fb19..400bb84e1f 100644
--- a/app/Models/Traits/HasUploads.php
+++ b/app/Models/Traits/HasUploads.php
@@ -7,7 +7,8 @@ use App\Models\Actionlog;
trait HasUploads
{
- public function uploads() {
+ public function uploads()
+ {
return $this->hasMany(Actionlog::class, 'item_id')
->where('item_type', self::class)
->where('action_type', '=', 'uploaded')
diff --git a/app/Models/Traits/Searchable.php b/app/Models/Traits/Searchable.php
index fb4d9b30ca..5ccae9a585 100644
--- a/app/Models/Traits/Searchable.php
+++ b/app/Models/Traits/Searchable.php
@@ -18,8 +18,8 @@ trait Searchable
/**
* Performs a search on the model, using the provided search terms
*
- * @param \Illuminate\Database\Eloquent\Builder $query The query to start the search on
- * @param string $search
+ * @param \Illuminate\Database\Eloquent\Builder $query The query to start the search on
+ * @param string $search
* @return \Illuminate\Database\Eloquent\Builder A query with added "where" clauses
*/
public function scopeTextSearch($query, $search)
@@ -51,6 +51,7 @@ trait Searchable
/**
* Prepares the search term, splitting and cleaning it up
+ *
* @param string $search The search term
* @return array An array of search terms
*/
@@ -63,7 +64,7 @@ trait Searchable
* Searches the models attributes for the search terms
*
* @param Illuminate\Database\Eloquent\Builder $query
- * @param array $terms
+ * @param array $terms
* @return Illuminate\Database\Eloquent\Builder
*/
private function searchAttributes(Builder $query, array $terms)
@@ -87,7 +88,7 @@ trait Searchable
* We need to form the query properly, starting with a "where",
* otherwise the generated select is wrong.
*
- * @todo This does the job, but is inelegant and fragile
+ * @todo This does the job, but is inelegant and fragile
*/
if (! $firstConditionAdded) {
$query = $query->where($table.'.'.$column, 'LIKE', '%'.$term.'%');
@@ -107,7 +108,7 @@ trait Searchable
* Searches the models custom fields for the search terms
*
* @param Illuminate\Database\Eloquent\Builder $query
- * @param array $terms
+ * @param array $terms
* @return Illuminate\Database\Eloquent\Builder
*/
private function searchCustomFields(Builder $query, array $terms)
@@ -135,45 +136,49 @@ trait Searchable
* Searches the models relations for the search terms
*
* @param Illuminate\Database\Eloquent\Builder $query
- * @param array $terms
+ * @param array $terms
* @return Illuminate\Database\Eloquent\Builder
*/
private function searchRelations(Builder $query, array $terms)
{
foreach ($this->getSearchableRelations() as $relation => $columns) {
- $query = $query->orWhereHas($relation, function ($query) use ($relation, $columns, $terms) {
- $table = $this->getRelationTable($relation);
-
- /**
- * We need to form the query properly, starting with a "where",
- * otherwise the generated nested select is wrong.
- *
- * @todo This does the job, but is inelegant and fragile
- */
- $firstConditionAdded = false;
-
- foreach ($columns as $column) {
- foreach ($terms as $term) {
- if (! $firstConditionAdded) {
- $query->where($table.'.'.$column, 'LIKE', '%'.$term.'%');
- $firstConditionAdded = true;
- continue;
+ $query = $query->orWhereHas(
+ $relation, function ($query) use ($relation, $columns, $terms) {
+ $table = $this->getRelationTable($relation);
+
+ /**
+ * We need to form the query properly, starting with a "where",
+ * otherwise the generated nested select is wrong.
+ *
+ * @todo This does the job, but is inelegant and fragile
+ */
+ $firstConditionAdded = false;
+
+ foreach ($columns as $column) {
+ foreach ($terms as $term) {
+ if (! $firstConditionAdded) {
+ $query->where($table.'.'.$column, 'LIKE', '%'.$term.'%');
+ $firstConditionAdded = true;
+ continue;
+ }
+
+ $query->orWhere($table.'.'.$column, 'LIKE', '%'.$term.'%');
}
-
- $query->orWhere($table.'.'.$column, 'LIKE', '%'.$term.'%');
}
- }
- // I put this here because I only want to add the concat one time in the end of the user relation search
- if(($relation == 'adminuser') || ($relation == 'user')) {
- $query->orWhereRaw(
- $this->buildMultipleColumnSearch([
+ // I put this here because I only want to add the concat one time in the end of the user relation search
+ if(($relation == 'adminuser') || ($relation == 'user')) {
+ $query->orWhereRaw(
+ $this->buildMultipleColumnSearch(
+ [
'users.first_name',
'users.last_name',
- ]),
+ ]
+ ),
["%{$term}%"]
);
+ }
}
- });
+ );
}
return $query;
@@ -185,7 +190,7 @@ trait Searchable
* This is a noop in this trait, but can be overridden in the implementing model, to allow more advanced searches
*
* @param Illuminate\Database\Eloquent\Builder $query
- * @param array $terms The search terms
+ * @param array $terms The search terms
* @return Illuminate\Database\Eloquent\Builder
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
@@ -268,7 +273,7 @@ trait Searchable
/**
* Builds a search string for either MySQL or sqlite by separating the provided columns with a space.
*
- * @param array $columns Columns to include in search string.
+ * @param array $columns Columns to include in search string.
* @return string
*/
private function buildMultipleColumnSearch(array $columns): string
@@ -288,9 +293,9 @@ trait Searchable
/**
* Search a string across multiple columns separated with a space.
*
- * @param Builder $query
- * @param array $columns - Columns to include in search string.
- * @param $term
+ * @param Builder $query
+ * @param array $columns - Columns to include in search string.
+ * @param $term
* @return Builder
*/
public function scopeOrWhereMultipleColumns($query, array $columns, $term)
diff --git a/app/Models/User.php b/app/Models/User.php
index 5cc5eb851e..c49af739ad 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -156,6 +156,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
*
* We only have to do this on the User model and no other models because other
* first-class objects have a name field.
+ *
* @return void
*/
@@ -165,13 +166,16 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
{
parent::boot();
- static::retrieved(function($user){
- $user->name = $user->getFullNameAttribute();
- });
+ static::retrieved(
+ function ($user) {
+ $user->name = $user->getFullNameAttribute();
+ }
+ );
}
- public function isAvatarExternal() {
+ public function isAvatarExternal()
+ {
// Check if it's a google avatar or some external avatar
if (Str::startsWith($this->avatar, ['http://', 'https://'])) {
return true;
@@ -223,7 +227,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* is authorized to do the thing
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return bool
*/
public function hasAccess($section)
@@ -239,7 +243,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Checks if the user is a SuperUser
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return bool
*/
public function isSuperUser()
@@ -252,10 +256,11 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Checks if the user can edit their own profile
*
* @author A. Gianotto <[email protected]>
- * @since [v6.3.4]
+ * @since [v6.3.4]
* @return bool
*/
- public function canEditProfile() : bool {
+ public function canEditProfile() : bool
+ {
$setting = Setting::getSettings();
if ($setting->profile_edit == 1) {
@@ -268,7 +273,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Checks if the user is deletable
*
* @author A. Gianotto <[email protected]>
- * @since [v6.3.4]
+ * @since [v6.3.4]
* @return bool
*/
public function isDeletable()
@@ -288,7 +293,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes the user -> company relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function company()
@@ -300,7 +305,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes the user -> department relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function department()
@@ -312,7 +317,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Checks activated status
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return bool
*/
public function isActivated()
@@ -325,7 +330,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Returns the full name attribute
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return string
*/
public function getFullNameAttribute()
@@ -343,7 +348,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes the user -> assets relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assets()
@@ -358,7 +363,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* created.
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assetmaintenances()
@@ -370,7 +375,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes the user -> accessories relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function accessories()
@@ -384,19 +389,19 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes the user -> consumables relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function consumables()
{
- return $this->belongsToMany(\App\Models\Consumable::class, 'consumables_users', 'assigned_to', 'consumable_id')->withPivot('id','created_at','note')->withTrashed();
+ return $this->belongsToMany(\App\Models\Consumable::class, 'consumables_users', 'assigned_to', 'consumable_id')->withPivot('id', 'created_at', 'note')->withTrashed();
}
/**
* Establishes the user -> license seats relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function licenses()
@@ -406,7 +411,6 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
/**
* Establishes the user -> reportTemplates relationship
- *
*/
public function reportTemplates(): HasMany
{
@@ -417,10 +421,11 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes a count of all items assigned
*
* @author J. Vinsmoke
- * @since [v6.1]
+ * @since [v6.1]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
- Public function allAssignedCount() {
+ Public function allAssignedCount()
+ {
$assetsCount = $this->assets()->count();
$licensesCount = $this->licenses()->count();
$accessoriesCount = $this->accessories()->count();
@@ -429,13 +434,13 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
$totalCount = $assetsCount + $licensesCount + $accessoriesCount + $consumablesCount;
return (int) $totalCount;
- }
+ }
/**
* Establishes the user -> actionlogs relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function userlog()
@@ -451,7 +456,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* @todo - this should be removed once we're sure we've switched it to location()
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function userloc()
@@ -463,7 +468,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes the user -> location relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v3.0]
+ * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function location()
@@ -475,7 +480,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes the user -> manager relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function manager()
@@ -487,7 +492,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes the user -> managed users relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v6.4.1]
+ * @since [v6.4.1]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function managesUsers()
@@ -500,7 +505,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes the user -> managed locations relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function managedLocations()
@@ -512,7 +517,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes the user -> groups relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function groups()
@@ -524,7 +529,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes the user -> assets relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v4.0]
+ * @since [v4.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function assetlog()
@@ -538,7 +543,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes the user -> acceptances relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v7.0.7]
+ * @since [v7.0.7]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function acceptances()
@@ -553,9 +558,9 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes the user -> eula relationship
*
* @return \Illuminate\Database\Eloquent\Relations\Relation
- * @since [v8.1.16]
+ * @since [v8.1.16]
* @author [Godfrey Martinez] [<[email protected]>]
- */
+ */
public function eulas()
{
return $this->hasMany(Actionlog::class, 'target_id')
@@ -572,7 +577,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Establishes the user -> requested assets relationship
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function checkoutRequests()
@@ -588,7 +593,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* - CSV import where no password was provided
*
* @author A. Gianotto <[email protected]>
- * @since [v6.2.0]
+ * @since [v6.2.0]
* @return string
*/
public function noPassword()
@@ -599,8 +604,9 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
/**
* Query builder scope to return NOT-deleted users
+ *
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
*
* @param string $query
* @return \Illuminate\Database\Query\Builder
@@ -614,7 +620,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Query builder scope to return users by email or username
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
*
* @param string $query
* @param string $user_username
@@ -632,7 +638,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Generate email from full name
*
* @author A. Gianotto <[email protected]>
- * @since [v2.0]
+ * @since [v2.0]
*
* @param string $query
* @return string
@@ -702,7 +708,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* 2 = 2FA universally required
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.0]
+ * @since [v4.0]
*
* @return bool
*/
@@ -731,7 +737,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* 2 = 2FA universally required
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v4.6.14]
+ * @since [v4.6.14]
*
* @return bool
*/
@@ -754,7 +760,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Get the admin user who created this user
*
* @author [A. Gianotto] [<[email protected]>]
- * @since [v6.0.5]
+ * @since [v6.0.5]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function createdBy()
@@ -767,7 +773,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Decode JSON permissions into array
*
* @author A. Gianotto <[email protected]>
- * @since [v1.0]
+ * @since [v1.0]
* @return array | \stdClass
*/
public function decodePermissions()
@@ -801,32 +807,37 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* all of the relations as well, which is more than what we need.
*
* @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param array $terms The search terms
+ * @param array $terms The search terms
* @return \Illuminate\Database\Query\Builder
*/
public function scopeSimpleNameSearch($query, $search)
{
return $query->where('first_name', 'LIKE', '%' . $search . '%')
->orWhere('last_name', 'LIKE', '%' . $search . '%')
- ->orWhereMultipleColumns([
+ ->orWhereMultipleColumns(
+ [
'users.first_name',
'users.last_name',
- ], $search);
+ ], $search
+ );
}
/**
* Run additional, advanced searches.
*
* @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param array $terms The search terms
+ * @param array $terms The search terms
* @return \Illuminate\Database\Eloquent\Builder
*/
- public function advancedTextSearch(Builder $query, array $terms) {
+ public function advancedTextSearch(Builder $query, array $terms)
+ {
foreach($terms as $term) {
- $query->orWhereMultipleColumns([
+ $query->orWhereMultipleColumns(
+ [
'users.first_name',
'users.last_name',
- ], $term);
+ ], $term
+ );
}
return $query;
@@ -836,22 +847,24 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* Query builder scope to return users by group
*
* @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param int $id
+ * @param int $id
* @return \Illuminate\Database\Query\Builder
*/
public function scopeByGroup($query, $id)
{
- return $query->whereHas('groups', function ($query) use ($id) {
- $query->where('permission_groups.id', '=', $id);
- });
+ return $query->whereHas(
+ 'groups', function ($query) use ($id) {
+ $query->where('permission_groups.id', '=', $id);
+ }
+ );
}
/**
* Query builder scope to order on manager
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -864,8 +877,8 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
/**
* Query builder scope to order on company
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -877,8 +890,8 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
/**
* Query builder scope to order on department
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -890,8 +903,8 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
/**
* Query builder scope to order on admin user
*
- * @param \Illuminate\Database\Query\Builder $query Query builder instance
- * @param string $order Order
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ * @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
@@ -907,8 +920,8 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
/**
* Query builder scope to order on company
*
- * @param Illuminate\Database\Query\Builder $query Query builder instance
- * @param text $order Order
+ * @param Illuminate\Database\Query\Builder $query Query builder instance
+ * @param text $order Order
*
* @return Illuminate\Database\Query\Builder Modified query builder
*/
@@ -926,14 +939,14 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
* This uses the HasLocalePreference contract to determine the user's preferred locale,
* used by Laravel's mail system to determine the locale for sending emails.
* https://laravel.com/docs/11.x/mail#user-preferred-locales
- *
*/
public function preferredLocale(): string
{
return $this->locale ?? Setting::getSettings()->locale ?? config('app.locale');
}
- public function getUserTotalCost(){
+ public function getUserTotalCost()
+ {
$asset_cost= 0;
$license_cost= 0;
$accessory_cost= 0;
@@ -955,10 +968,11 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
return $this;
}
- public function scopeUserLocation($query, $location, $search){
+ public function scopeUserLocation($query, $location, $search)
+ {
- return $query->where('location_id','=', $location)
+ return $query->where('location_id', '=', $location)
->where('users.first_name', 'LIKE', '%' . $search . '%')
->orWhere('users.email', 'LIKE', '%' . $search . '%')
->orWhere('users.last_name', 'LIKE', '%' . $search . '%')
@@ -1002,7 +1016,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
/**
* Recursive helper function to fetch subordinates.
*
- * @param User $manager
+ * @param User $manager
* @param \Illuminate\Support\Collection $subs
*/
protected function fetchSubordinatesRecursive(User $manager, \Illuminate\Support\Collection &$subs)
@@ -1023,7 +1037,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
/**
* Check if the current user is a direct or indirect manager of the given user.
*
- * @param User $userToCheck
+ * @param User $userToCheck
* @return bool
*/
public function isManagerOf(User $userToCheck): bool