-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added is_flying Attribute to User Model #1729
base: dev
Are you sure you want to change the base?
Changes from all commits
0d3bf8f
e7479a1
cfad573
2fbbb06
895eab3
403b1b1
e572b48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
namespace App\Models; | ||
|
||
use App\Models\Enums\JournalType; | ||
use App\Models\Enums\PirepState; | ||
use App\Models\Traits\JournalTrait; | ||
use Illuminate\Contracts\Auth\MustVerifyEmail; | ||
use Illuminate\Database\Eloquent\Casts\Attribute; | ||
|
@@ -27,6 +28,7 @@ | |
* @property string callsign | ||
* @property string name | ||
* @property string name_private Only first name, rest are initials | ||
* @property bool is_flying | ||
* @property string email | ||
* @property string password | ||
* @property string api_key | ||
|
@@ -66,7 +68,6 @@ | |
* @property Airport location | ||
* @property Bid[] bids | ||
* | ||
* @mixin \Illuminate\Database\Eloquent\Builder | ||
* @mixin \Illuminate\Notifications\Notifiable | ||
* @mixin \Laratrust\Traits\HasRolesAndPermissions | ||
*/ | ||
|
@@ -216,6 +217,20 @@ public function atc(): Attribute | |
); | ||
} | ||
|
||
/** | ||
* Returns a boolean value whether the pilot is actively flying or not. | ||
* | ||
* @return Attribute | ||
*/ | ||
public function isFlying(): Attribute | ||
{ | ||
return Attribute::make( | ||
get: function ($_, $attrs) { | ||
return (bool) Pirep::where(['user_id' => $this->id, 'state' => PirepState::IN_PROGRESS])->count(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would change this to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the name also to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also, instead of |
||
} | ||
); | ||
} | ||
|
||
/** | ||
* Return a "privatized" version of someones name - First and middle names full, last name initials | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should go in the bottom of the list where the properties are
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And to
in_flight