diff --git a/app/Models/User.php b/app/Models/User.php index 61493d391..fe7fe280f 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -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(); + } + ); + } + /** * Return a "privatized" version of someones name - First and middle names full, last name initials * diff --git a/composer.json b/composer.json index b47bf2d29..db1f0cc1b 100644 --- a/composer.json +++ b/composer.json @@ -91,7 +91,8 @@ "nikolaposa/version": "^4.2", "spatie/laravel-activitylog": "^4.7", "socialiteproviders/vatsim": "^5.0", - "socialiteproviders/ivao": "^4.0" + "socialiteproviders/ivao": "^4.0", + "mailersend/laravel-driver": "^2.6" }, "require-dev": { "barryvdh/laravel-debugbar": "^3.8.1", diff --git a/config/mail.php b/config/mail.php index 76ee043d8..16fa3ee9b 100755 --- a/config/mail.php +++ b/config/mail.php @@ -33,6 +33,10 @@ 'path' => '/usr/sbin/sendmail -bs', ], + 'mailersend' => [ + 'transport' => 'mailersend', + ], + 'log' => [ 'transport' => 'log', 'channel' => env('MAIL_LOG_CHANNEL', 'stack'),