Skip to content

Commit

Permalink
Add Notes attribute to Resident model
Browse files Browse the repository at this point in the history
- Mutations for nullable fields added to MedHistory, Medicine, and Resident models
- composer.json updated to use latest versions:
    - doctrine/dbal
    - illuminate/database
    - php-di/php-di
    - respect/validatiion
    - vlucas/phpdotenv
    - "php": "^8.0" (was ^7.4 || 8.0)
  • Loading branch information
RyanNerd committed May 20, 2021
1 parent 4610b2c commit 36d247f
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 6 deletions.
13 changes: 13 additions & 0 deletions app/Models/MedHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,17 @@ class MedHistory extends ModelBase
];

protected $table = 'MedHistory';

/**
* Override Notes to null if empty string
* @param string|null $value
*/
public function setNotesAttribute(?string $value)
{
if (empty($value)) {
$this->attributes['Notes'] = null;
} else {
$this->attributes['Notes'] = $value;
}
}
}
39 changes: 39 additions & 0 deletions app/Models/Medicine.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,43 @@ class Medicine extends ModelBase
];

protected $table = 'Medicine';

/**
* Override Strength field to null if empty string
* @param string|null $value
*/
public function setStrengthAttribute(?string $value)
{
if (empty($value)) {
$this->attributes['Strength'] = null;
} else {
$this->attributes['Strength'] = $value;
}
}

/**
* Override Barcode field to null if empty string
* @param string|null $value
*/
public function setBarcodeAttribute(?string $value)
{
if (empty($value)) {
$this->attributes['Barcode'] = null;
} else {
$this->attributes['Barcode'] = $value;
}
}

/**
* Override Directions field to null if empty string
* @param string|null $value
*/
public function setDirectionsAttribute(?string $value)
{
if (empty($value)) {
$this->attributes['Directions'] = null;
} else {
$this->attributes['Directions'] = $value;
}
}
}
13 changes: 13 additions & 0 deletions app/Models/Resident.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,17 @@ class Resident extends ModelBase
protected $table = 'Resident';

public bool $allowAll = true;

/**
* Override Notes to null if empty string
* @param string|null $value
*/
public function setNotesAttribute(?string $value)
{
if (empty($value)) {
$this->attributes['Notes'] = null;
} else {
$this->attributes['Notes'] = $value;
}
}
}
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
"sort-packages": true
},
"require": {
"php": "^7.4 || 8.0",
"php": "^8.0",
"ext-json": "*",
"ext-pdo": "*",
"doctrine/dbal": "^3.0.0",
"illuminate/database": "^v8.18.1",
"doctrine/dbal": "^3.1.0",
"illuminate/database": "^v8.40.0",
"league/climate": "^3.7.0",
"php-di/php-di": "^6.3.0",
"respect/validation": "^2.1.0",
"php-di/php-di": "^6.3.3",
"respect/validation": "^2.2.3",
"slim/psr7": "^1.3.0",
"slim/slim": "^4.7.1",
"vlucas/phpdotenv": "^v3.6.7"
"vlucas/phpdotenv": "^v3.6.8"
},
"require-dev": {
"consolidation/robo": "2.2.2",
Expand Down

0 comments on commit 36d247f

Please sign in to comment.