Update UserFieldValue Model (#1344)
* Add `name` attribute * Pre-StyleFix * Update UserFieldValue.php * Used optional() * Update Pirep.php * Update Flight.php * Update User.php
This commit is contained in:
@@ -140,7 +140,7 @@ class Flight extends Model
|
|||||||
*/
|
*/
|
||||||
public function getIdentAttribute(): string
|
public function getIdentAttribute(): string
|
||||||
{
|
{
|
||||||
$flight_id = $this->airline->code;
|
$flight_id = optional($this->airline)->code;
|
||||||
$flight_id .= $this->flight_number;
|
$flight_id .= $this->flight_number;
|
||||||
|
|
||||||
if (filled($this->route_code)) {
|
if (filled($this->route_code)) {
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ class Pirep extends Model
|
|||||||
*/
|
*/
|
||||||
public function getIdentAttribute(): string
|
public function getIdentAttribute(): string
|
||||||
{
|
{
|
||||||
$flight_id = $this->airline->code;
|
$flight_id = optional($this->airline)->code;
|
||||||
$flight_id .= $this->flight_number;
|
$flight_id .= $this->flight_number;
|
||||||
|
|
||||||
if (filled($this->route_code)) {
|
if (filled($this->route_code)) {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class User extends Authenticatable
|
|||||||
{
|
{
|
||||||
$length = setting('pilots.id_length');
|
$length = setting('pilots.id_length');
|
||||||
|
|
||||||
return $this->airline->icao.str_pad($this->pilot_id, $length, '0', STR_PAD_LEFT);
|
return optional($this->airline)->icao.str_pad($this->pilot_id, $length, '0', STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,6 +22,14 @@ class UserFieldValue extends Model
|
|||||||
|
|
||||||
public static $rules = [];
|
public static $rules = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return related field's name along with field values
|
||||||
|
*/
|
||||||
|
public function getNameAttribute(): string
|
||||||
|
{
|
||||||
|
return optional($this->field)->name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Foreign Keys
|
* Foreign Keys
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user