Compare commits
74 Commits
master
...
807-Fuel-C
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2bcd72e39 | ||
|
|
5dcbd01c00 | ||
|
|
c6d12802a4 | ||
|
|
07de33605b | ||
|
|
ec9ef9c1c2 | ||
|
|
23962a1abb | ||
|
|
9a735d2935 | ||
|
|
51004b143c | ||
|
|
50a0b89caa | ||
|
|
e99c22b007 | ||
|
|
55fa01478d | ||
|
|
552196ce57 | ||
|
|
7aa089bd88 | ||
|
|
1e4b0d629a | ||
|
|
febfff5f12 | ||
|
|
cdf7b13b5b | ||
|
|
51186bed7c | ||
|
|
ac1dc49377 | ||
|
|
be72571185 | ||
|
|
d3e6d2c49a | ||
|
|
4fa58cec5a | ||
|
|
27316f96e8 | ||
|
|
e5ed66b372 | ||
|
|
ee6982f558 | ||
|
|
4f46e75515 | ||
|
|
3ac03d9716 | ||
|
|
ace7c42557 | ||
|
|
3ebf4f2924 | ||
|
|
3739cc8e91 | ||
|
|
bbb5f1d13c | ||
|
|
64e4c91e7e | ||
|
|
3e2b1fe42b | ||
|
|
420bd7e4ae | ||
|
|
e4b1c238f3 | ||
|
|
57e91027c8 | ||
|
|
475ad3a66d | ||
|
|
340f52112d | ||
|
|
c6482bd160 | ||
|
|
df15053b75 | ||
|
|
04b8be1649 | ||
|
|
3d211535f7 | ||
|
|
c1408cb8fe | ||
|
|
519ae600d5 | ||
|
|
82bae9cc74 | ||
|
|
3a07e34259 | ||
|
|
89ca0b49a2 | ||
|
|
5b16c88bcb | ||
|
|
c67e45e98e | ||
|
|
688be6f75a | ||
|
|
8527b39fe2 | ||
|
|
a443908bed | ||
|
|
c46fc9171c | ||
|
|
71c09aaeb1 | ||
|
|
5046d26032 | ||
|
|
4cd7eef937 | ||
|
|
f17cd15b01 | ||
|
|
5f8053226e | ||
|
|
09cd7adb6b | ||
|
|
fb7d988032 | ||
|
|
eb90d08761 | ||
|
|
1ebb181c36 | ||
|
|
975ee9b88e | ||
|
|
52379c3789 | ||
|
|
bcf7acf957 | ||
|
|
3b1936e110 | ||
|
|
b9aeda1cba | ||
|
|
00505a1607 | ||
|
|
6ebbe0209e | ||
|
|
5754103a17 | ||
|
|
6078163d75 | ||
|
|
885e1d599e | ||
|
|
876457af71 | ||
|
|
8c75bd098e | ||
|
|
585c9578e8 |
@@ -6,7 +6,6 @@ language: php
|
||||
php:
|
||||
- '7.4'
|
||||
- '7.3'
|
||||
- '7.2'
|
||||
|
||||
#env:
|
||||
# - DB=mysql
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
<directory suffix=".php">./app</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<listeners>
|
||||
<!--<listeners>
|
||||
<listener class="NunoMaduro\Collision\Adapters\Phpunit\Listener"/>
|
||||
</listeners>
|
||||
</listeners>-->
|
||||
<php>
|
||||
<ini name="error_reporting" value="E_ALL"/>
|
||||
<ini name="display_errors" value="On"/>
|
||||
|
||||
8
Makefile
8
Makefile
@@ -43,7 +43,7 @@ build:
|
||||
# This is to build all the stylesheets, etc
|
||||
.PHONY: build-assets
|
||||
build-assets:
|
||||
yarn run production
|
||||
npm run production
|
||||
|
||||
.PHONY: install
|
||||
install: build
|
||||
@@ -74,9 +74,9 @@ reload-db:
|
||||
tests: test
|
||||
|
||||
.PHONY: test
|
||||
test: phpcs
|
||||
#php artisan database:create --reset
|
||||
vendor/bin/phpunit --debug --verbose
|
||||
test:
|
||||
@#php artisan database:create --reset
|
||||
@vendor/bin/phpunit --verbose
|
||||
|
||||
.PHONY: phpcs
|
||||
phpcs:
|
||||
|
||||
@@ -14,7 +14,7 @@ A full distribution, with all of the composer dependencies, is available at this
|
||||
|
||||
## Requirements
|
||||
|
||||
- PHP 7.1+, extensions:
|
||||
- PHP 7.3+, extensions:
|
||||
- cURL
|
||||
- JSON
|
||||
- mbstring
|
||||
|
||||
@@ -79,6 +79,13 @@ class CreateDatabase extends Command
|
||||
*/
|
||||
protected function create_sqlite($dbkey)
|
||||
{
|
||||
$dbPath = config($dbkey.'database');
|
||||
|
||||
// Skip if running in memory
|
||||
if ($dbPath === ':memory:') {
|
||||
return;
|
||||
}
|
||||
|
||||
$exec = 'sqlite3';
|
||||
if ($this->os->isWindowsLike()) {
|
||||
$exec = 'sqlite3.exe';
|
||||
@@ -89,11 +96,11 @@ class CreateDatabase extends Command
|
||||
$this->runCommand($cmd);
|
||||
}
|
||||
|
||||
if (!file_exists(config($dbkey.'database'))) {
|
||||
if (!file_exists($dbPath)) {
|
||||
$cmd = [
|
||||
$exec,
|
||||
config($dbkey.'database'),
|
||||
'""',
|
||||
$dbPath,
|
||||
'".exit"',
|
||||
];
|
||||
|
||||
$this->runCommand($cmd);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use function is_array;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
@@ -82,9 +83,9 @@ abstract class Command extends \Illuminate\Console\Command
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $cmd
|
||||
* @param bool $return
|
||||
* @param mixed $verbose
|
||||
* @param array|string $cmd
|
||||
* @param bool $return
|
||||
* @param mixed $verbose
|
||||
*
|
||||
* @throws \Symfony\Component\Process\Exception\RuntimeException
|
||||
* @throws \Symfony\Component\Process\Exception\LogicException
|
||||
@@ -93,16 +94,16 @@ abstract class Command extends \Illuminate\Console\Command
|
||||
*/
|
||||
public function runCommand($cmd, $return = false, $verbose = true): string
|
||||
{
|
||||
if (\is_array($cmd)) {
|
||||
if (is_array($cmd)) {
|
||||
$cmd = implode(' ', $cmd);
|
||||
}
|
||||
|
||||
if ($verbose) {
|
||||
$this->info('Running "'.$cmd.'"');
|
||||
$this->info('Running '.$cmd);
|
||||
}
|
||||
|
||||
$val = '';
|
||||
$process = new Process($cmd);
|
||||
$process = Process::fromShellCommandline($cmd);
|
||||
$process->run(function ($type, $buffer) use ($return, &$val) {
|
||||
if ($return) {
|
||||
$val .= $buffer;
|
||||
|
||||
12
app/Contracts/Event.php
Normal file
12
app/Contracts/Event.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Event
|
||||
{
|
||||
use Dispatchable;
|
||||
use SerializesModels;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ abstract class Listener
|
||||
public function subscribe(Dispatcher $events): void
|
||||
{
|
||||
foreach (static::$callbacks as $klass => $cb) {
|
||||
$events->listen($klass, get_class($this).'@'.$cb);
|
||||
$events->listen($klass, static::class.'@'.$cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class BaseNotification extends Notification implements ShouldQueue
|
||||
class Notification extends \Illuminate\Notifications\Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public $channels = [];
|
||||
public $requires_opt_in = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Look in the notifications.channels config and see where this particular
|
||||
// notification can go. Map it to $channels
|
||||
$klass = get_class($this);
|
||||
$klass = static::class;
|
||||
$notif_config = config('notifications.channels', []);
|
||||
if (!array_key_exists($klass, $notif_config)) {
|
||||
Log::error('Notification type '.$klass.' missing from notifications config, defaulting to mail');
|
||||
@@ -6,7 +6,8 @@ use Illuminate\Validation\Validator;
|
||||
use Prettus\Repository\Eloquent\BaseRepository;
|
||||
|
||||
/**
|
||||
* @mixin \Prettus\Repository\Eloquent\BaseRepository
|
||||
* @mixin Model
|
||||
* @mixin BaseRepository
|
||||
*/
|
||||
abstract class Repository extends BaseRepository
|
||||
{
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* Base class for a resource/response
|
||||
*/
|
||||
class Resource extends \Illuminate\Http\Resources\Json\Resource
|
||||
class Resource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Iterate through the list of $fields and check if they're a "Unit"
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Airport;
|
||||
use App\Models\Enums\AircraftState;
|
||||
use App\Models\Enums\AircraftStatus;
|
||||
use App\Models\Subfleet;
|
||||
use App\Support\ICAO;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Models\Aircraft::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => null,
|
||||
'subfleet_id' => function () {
|
||||
return factory(App\Models\Subfleet::class)->create()->id;
|
||||
return factory(Subfleet::class)->create()->id;
|
||||
},
|
||||
'airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
return factory(Airport::class)->create()->id;
|
||||
},
|
||||
'iata' => $faker->unique()->text(5),
|
||||
'icao' => $faker->unique()->text(5),
|
||||
'name' => $faker->text(50),
|
||||
'registration' => $faker->unique()->text(10),
|
||||
'hex_code' => \App\Support\ICAO::createHexCode(),
|
||||
'hex_code' => ICAO::createHexCode(),
|
||||
'mtow' => $faker->randomFloat(2, 0, 50000),
|
||||
'zfw' => $faker->randomFloat(2, 0, 50000),
|
||||
'status' => \App\Models\Enums\AircraftStatus::ACTIVE,
|
||||
'state' => \App\Models\Enums\AircraftState::PARKED,
|
||||
'status' => AircraftStatus::ACTIVE,
|
||||
'state' => AircraftState::PARKED,
|
||||
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
|
||||
'updated_at' => function (array $pirep) {
|
||||
return $pirep['created_at'];
|
||||
|
||||
@@ -9,7 +9,7 @@ use Hashids\Hashids;
|
||||
$factory->define(App\Models\Airline::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => null,
|
||||
'icao' => function (array $apt) use ($faker) {
|
||||
'icao' => function (array $apt) {
|
||||
$hashids = new Hashids(microtime(), 5);
|
||||
$mt = str_replace('.', '', microtime(true));
|
||||
|
||||
|
||||
@@ -8,19 +8,19 @@ $factory->define(App\Models\Flight::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => $faker->unique()->numberBetween(10, 10000000),
|
||||
'airline_id' => function () {
|
||||
return factory(App\Models\Airline::class)->create()->id;
|
||||
return factory(\App\Models\Airline::class)->create()->id;
|
||||
},
|
||||
'flight_number' => $faker->unique()->numberBetween(10, 1000000),
|
||||
'route_code' => $faker->randomElement(['', $faker->text(5)]),
|
||||
'route_leg' => $faker->randomElement(['', $faker->numberBetween(0, 1000)]),
|
||||
'dpt_airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
return factory(\App\Models\Airport::class)->create()->id;
|
||||
},
|
||||
'arr_airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
return factory(\App\Models\Airport::class)->create()->id;
|
||||
},
|
||||
'alt_airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
return factory(\App\Models\Airport::class)->create()->id;
|
||||
},
|
||||
'distance' => $faker->numberBetween(1, 1000),
|
||||
'route' => null,
|
||||
|
||||
@@ -6,7 +6,7 @@ $factory->define(App\Models\JournalTransactions::class, function (Faker $faker)
|
||||
return [
|
||||
'transaction_group' => \Ramsey\Uuid\Uuid::uuid4()->toString(),
|
||||
'journal_id' => function () {
|
||||
return factory(App\Models\Journal::class)->create()->id;
|
||||
return factory(\App\Models\Journal::class)->create()->id;
|
||||
},
|
||||
'credit' => $faker->numberBetween(100, 10000),
|
||||
'debit' => $faker->numberBetween(100, 10000),
|
||||
|
||||
@@ -6,7 +6,7 @@ $factory->define(App\Models\News::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => null,
|
||||
'user_id' => function () {
|
||||
return factory(App\Models\User::class)->create()->id;
|
||||
return factory(\App\Models\User::class)->create()->id;
|
||||
},
|
||||
'subject' => $faker->text(),
|
||||
'body' => $faker->sentence,
|
||||
|
||||
@@ -10,8 +10,8 @@ use Faker\Generator as Faker;
|
||||
* Create a new PIREP
|
||||
*/
|
||||
$factory->define(App\Models\Pirep::class, function (Faker $faker) {
|
||||
$airline = factory(App\Models\Airline::class)->create();
|
||||
$flight = factory(App\Models\Flight::class)->create([
|
||||
$airline = factory(\App\Models\Airline::class)->create();
|
||||
$flight = factory(\App\Models\Flight::class)->create([
|
||||
'airline_id' => $airline->id,
|
||||
]);
|
||||
|
||||
@@ -21,10 +21,10 @@ $factory->define(App\Models\Pirep::class, function (Faker $faker) {
|
||||
return $airline->id;
|
||||
},
|
||||
'user_id' => function () {
|
||||
return factory(App\Models\User::class)->create()->id;
|
||||
return factory(\App\Models\User::class)->create()->id;
|
||||
},
|
||||
'aircraft_id' => function () {
|
||||
return factory(App\Models\Aircraft::class)->create()->id;
|
||||
return factory(\App\Models\Aircraft::class)->create()->id;
|
||||
},
|
||||
'flight_id' => function () use ($flight) {
|
||||
return $flight->id;
|
||||
|
||||
@@ -6,7 +6,7 @@ $factory->define(App\Models\Subfleet::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => null,
|
||||
'airline_id' => function () {
|
||||
return factory(App\Models\Airline::class)->create()->id;
|
||||
return factory(\App\Models\Airline::class)->create()->id;
|
||||
},
|
||||
'name' => $faker->unique()->text(50),
|
||||
'type' => $faker->unique()->text(7),
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Airline;
|
||||
use App\Models\Enums\UserState;
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
$factory->define(App\Models\User::class, function (Faker $faker) {
|
||||
static $password;
|
||||
@@ -14,7 +16,7 @@ $factory->define(App\Models\User::class, function (Faker $faker) {
|
||||
'password' => $password ?: $password = Hash::make('secret'),
|
||||
'api_key' => $faker->sha1,
|
||||
'airline_id' => function () {
|
||||
return factory(App\Models\Airline::class)->create()->id;
|
||||
return factory(Airline::class)->create()->id;
|
||||
},
|
||||
'rank_id' => 1,
|
||||
'flights' => $faker->numberBetween(0, 1000),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Enums\PageType;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@@ -22,7 +23,7 @@ class CreatePages extends Migration
|
||||
$table->string('name');
|
||||
$table->string('slug');
|
||||
$table->string('icon');
|
||||
$table->unsignedSmallInteger('type');
|
||||
$table->unsignedSmallInteger('type')->default(PageType::PAGE);
|
||||
$table->boolean('public');
|
||||
$table->boolean('enabled');
|
||||
$table->mediumText('body');
|
||||
|
||||
36
app/Database/migrations/2020_06_09_141153_pages_add_link.php
Normal file
36
app/Database/migrations/2020_06_09_141153_pages_add_link.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class PagesAddLink extends Migration
|
||||
{
|
||||
/**
|
||||
* Add a `link` column and make the body optional. Also add a "new_window" bool
|
||||
* which determines if we open this link in a new window or not
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('pages', function (Blueprint $table) {
|
||||
$table->string('body')->change()->nullable();
|
||||
$table->string('link')
|
||||
->default('')
|
||||
->nullable()
|
||||
->after('body');
|
||||
|
||||
$table->boolean('new_window')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('fares', function (Blueprint $table) {
|
||||
$table->dropColumn('link');
|
||||
$table->dropColumn('new_window');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use App\Contracts\Model;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateUserFields extends Migration
|
||||
{
|
||||
/**
|
||||
* Add two tables for holding user fields and the values
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
/*
|
||||
* Hold a master list of fields
|
||||
*/
|
||||
Schema::create('user_fields', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name', 200);
|
||||
$table->text('description')->nullable();
|
||||
$table->boolean('show_on_registration')->default(false)->nullable();
|
||||
$table->boolean('required')->default(false)->nullable();
|
||||
$table->boolean('private')->default(false)->nullable();
|
||||
$table->boolean('active')->default(true)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
/*
|
||||
* The values for the actual fields
|
||||
*/
|
||||
Schema::create('user_field_values', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('user_field_id');
|
||||
$table->string('user_id', Model::ID_MAX_LENGTH);
|
||||
$table->text('value')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['user_field_id', 'user_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Add a `mtow` column for the max takeoff weight
|
||||
*/
|
||||
class AircraftAddMtow extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('aircraft', function (Blueprint $table) {
|
||||
$table->unsignedDecimal('mtow')
|
||||
->nullable()
|
||||
->default(0.0)
|
||||
->after('hex_code');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('aircraft', function (Blueprint $table) {
|
||||
$table->dropColumn('mtow');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -12,3 +12,11 @@ airlines:
|
||||
active: 1
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- id: 2
|
||||
icao: XXX
|
||||
iata: XX
|
||||
name: inactive airline
|
||||
country: us
|
||||
active: 0
|
||||
created_at: now
|
||||
updated_at: now
|
||||
|
||||
@@ -69,3 +69,26 @@ role_user:
|
||||
- user_id: 3
|
||||
role_id: 2
|
||||
user_type: App\Models\User
|
||||
|
||||
user_fields:
|
||||
- id: 1
|
||||
name: 'VATSIM ID'
|
||||
show_on_registration: true
|
||||
required: false
|
||||
private: false
|
||||
- id: 2
|
||||
name: 'Referral'
|
||||
description: 'Who referred you'
|
||||
show_on_registration: true
|
||||
required: false
|
||||
private: true
|
||||
|
||||
user_field_values:
|
||||
- id: 1
|
||||
user_field_id: 1
|
||||
user_id: 1
|
||||
value: 'my vatsim id'
|
||||
- id: 2
|
||||
user_field_id: 2
|
||||
user_id: 1
|
||||
value: 'Nobody did'
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
- name: admin-access
|
||||
display_name: Admin Panel
|
||||
description: Access the admin panel
|
||||
- name: aircraft
|
||||
display_name: Aircraft
|
||||
description: Create/edit aircraft
|
||||
- name: airlines
|
||||
display_name: Airlines
|
||||
description: Create/edit airlines
|
||||
|
||||
@@ -26,6 +26,13 @@
|
||||
options:
|
||||
type: boolean
|
||||
description: If an airport isn't added, try to look it up when adding schedules
|
||||
- key: general.allow_unadded_airports
|
||||
name: 'Allow unadded airports'
|
||||
group: general
|
||||
value: false
|
||||
options:
|
||||
type: boolean
|
||||
description: If an un-added airport is used, it is looked up and added
|
||||
- key: general.check_prerelease_version
|
||||
name: 'Pre-release versions in version check'
|
||||
group: general
|
||||
|
||||
22
app/Events/AcarsUpdate.php
Normal file
22
app/Events/AcarsUpdate.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
use App\Models\Acars;
|
||||
use App\Models\Pirep;
|
||||
|
||||
class AcarsUpdate extends Event
|
||||
{
|
||||
/** @var Pirep */
|
||||
public $pirep;
|
||||
|
||||
/** @var Acars */
|
||||
public $acars;
|
||||
|
||||
public function __construct(Pirep $pirep, Acars $acars)
|
||||
{
|
||||
$this->pirep = $pirep;
|
||||
$this->acars = $acars;
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,11 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Contracts\Event;
|
||||
|
||||
class BaseEvent
|
||||
/**
|
||||
* @deprecated Extend App\Contracts\Event directly
|
||||
*/
|
||||
class BaseEvent extends Event
|
||||
{
|
||||
use Dispatchable;
|
||||
use InteractsWithSockets;
|
||||
use SerializesModels;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
class CronHourly extends BaseEvent
|
||||
use App\Contracts\Event;
|
||||
|
||||
class CronHourly extends Event
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
|
||||
/**
|
||||
* This event is dispatched when the monthly cron is run
|
||||
* It happens after all of the default nightly tasks
|
||||
*/
|
||||
class CronMonthly extends BaseEvent
|
||||
class CronMonthly extends Event
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
|
||||
/**
|
||||
* This event is dispatched when the daily cron is run
|
||||
* It happens after all of the default nightly tasks
|
||||
*/
|
||||
class CronNightly extends BaseEvent
|
||||
class CronNightly extends Event
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
|
||||
/**
|
||||
* This event is dispatched when the weekly cron is run
|
||||
* It happens after all of the default nightly tasks
|
||||
*/
|
||||
class CronWeekly extends BaseEvent
|
||||
class CronWeekly extends Event
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
use App\Models\Pirep;
|
||||
|
||||
/**
|
||||
@@ -25,7 +26,7 @@ use App\Models\Pirep;
|
||||
*
|
||||
* The event will have a copy of the PIREP model, if it's applicable
|
||||
*/
|
||||
class Expenses extends BaseEvent
|
||||
class Expenses extends Event
|
||||
{
|
||||
public $pirep;
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
use App\Models\News;
|
||||
|
||||
class NewsAdded extends BaseEvent
|
||||
class NewsAdded extends Event
|
||||
{
|
||||
public $news;
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
use App\Models\Pirep;
|
||||
|
||||
class PirepAccepted extends BaseEvent
|
||||
class PirepAccepted extends Event
|
||||
{
|
||||
public $pirep;
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
use App\Models\Pirep;
|
||||
|
||||
class PirepCancelled extends BaseEvent
|
||||
class PirepCancelled extends Event
|
||||
{
|
||||
public $pirep;
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
use App\Models\Pirep;
|
||||
|
||||
class PirepFiled extends BaseEvent
|
||||
class PirepFiled extends Event
|
||||
{
|
||||
public $pirep;
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
use App\Models\Pirep;
|
||||
|
||||
class PirepPrefiled extends BaseEvent
|
||||
class PirepPrefiled extends Event
|
||||
{
|
||||
public $pirep;
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
use App\Models\Pirep;
|
||||
|
||||
class PirepRejected extends BaseEvent
|
||||
class PirepRejected extends Event
|
||||
{
|
||||
public $pirep;
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
use App\Models\Pirep;
|
||||
|
||||
class PirepUpdated extends BaseEvent
|
||||
class PirepUpdated extends Event
|
||||
{
|
||||
public $pirep;
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
use App\Models\User;
|
||||
|
||||
class TestEvent extends BaseEvent
|
||||
class TestEvent extends Event
|
||||
{
|
||||
public $user;
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
use App\Models\User;
|
||||
|
||||
class UserAccepted extends BaseEvent
|
||||
class UserAccepted extends Event
|
||||
{
|
||||
public $user;
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
use App\Models\User;
|
||||
|
||||
class UserRegistered extends BaseEvent
|
||||
class UserRegistered extends Event
|
||||
{
|
||||
public $user;
|
||||
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Event triggered when a user's state changes
|
||||
*/
|
||||
class UserStateChanged extends BaseEvent
|
||||
class UserStateChanged extends Event
|
||||
{
|
||||
public $old_state;
|
||||
public $user;
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Contracts\Event;
|
||||
use App\Models\User;
|
||||
|
||||
class UserStatsChanged extends BaseEvent
|
||||
class UserStatsChanged extends Event
|
||||
{
|
||||
public $stat_name;
|
||||
public $old_value;
|
||||
|
||||
47
app/Exceptions/AircraftInvalid.php
Normal file
47
app/Exceptions/AircraftInvalid.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use App\Models\Aircraft;
|
||||
|
||||
class AircraftInvalid extends AbstractHttpException
|
||||
{
|
||||
public const MESSAGE = 'The supplied aircraft is invalid';
|
||||
|
||||
private $aircraft;
|
||||
|
||||
public function __construct(Aircraft $aircraft)
|
||||
{
|
||||
$this->aircraft = $aircraft;
|
||||
parent::__construct(
|
||||
400,
|
||||
static::MESSAGE
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the RFC 7807 error type (without the URL root)
|
||||
*/
|
||||
public function getErrorType(): string
|
||||
{
|
||||
return 'aircraft-invalid';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the detailed error string
|
||||
*/
|
||||
public function getErrorDetails(): string
|
||||
{
|
||||
return $this->getMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array with the error details, merged with the RFC7807 response
|
||||
*/
|
||||
public function getErrorMetadata(): array
|
||||
{
|
||||
return [
|
||||
'aircraft_id' => optional($this->aircraft)->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,13 @@
|
||||
namespace App\Exceptions\Converters;
|
||||
|
||||
use App\Exceptions\AbstractHttpException;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class GenericExceptionAbstract extends AbstractHttpException
|
||||
{
|
||||
private $exception;
|
||||
|
||||
public function __construct(Exception $exception)
|
||||
public function __construct(Throwable $exception)
|
||||
{
|
||||
$this->exception = $exception;
|
||||
parent::__construct(
|
||||
|
||||
@@ -5,8 +5,7 @@ namespace App\Exceptions;
|
||||
use App\Exceptions\Converters\GenericExceptionAbstract;
|
||||
use App\Exceptions\Converters\SymfonyException;
|
||||
use App\Exceptions\Converters\ValidationException;
|
||||
use Exception;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use App\Http\Middleware\SetActiveTheme;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
@@ -15,10 +14,9 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\ValidationException as IlluminateValidationException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException as SymfonyHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Throwable;
|
||||
use Whoops\Handler\HandlerInterface;
|
||||
|
||||
/**
|
||||
@@ -42,19 +40,19 @@ class Handler extends ExceptionHandler
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Exception $exception
|
||||
* @param Request $request
|
||||
* @param \Throwable $exception
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
public function render($request, Throwable $exception)
|
||||
{
|
||||
if ($request->is('api/*')) {
|
||||
return $this->handleApiError($request, $exception);
|
||||
}
|
||||
|
||||
if ($exception instanceof AbstractHttpException
|
||||
&& $exception->getStatusCode() === 403) {
|
||||
(new SetActiveTheme())->setTheme($request);
|
||||
if ($exception instanceof AbstractHttpException && $exception->getStatusCode() === 403) {
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
|
||||
@@ -65,11 +63,11 @@ class Handler extends ExceptionHandler
|
||||
* Handle errors in the API
|
||||
*
|
||||
* @param $request
|
||||
* @param \Exception $exception
|
||||
* @param \Throwable $exception
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response
|
||||
*/
|
||||
private function handleApiError($request, Exception $exception)
|
||||
private function handleApiError($request, Throwable $exception)
|
||||
{
|
||||
Log::error('API Error', $exception->getTrace());
|
||||
|
||||
@@ -118,38 +116,13 @@ class Handler extends ExceptionHandler
|
||||
{
|
||||
if ($request->expectsJson() || $request->is('api/*')) {
|
||||
$error = new Unauthenticated();
|
||||
|
||||
return $error->getResponse();
|
||||
}
|
||||
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the given HttpException.
|
||||
*
|
||||
* @param AbstractHttpException $e
|
||||
*
|
||||
* @return \Illuminate\Http\Response|Response
|
||||
*/
|
||||
protected function renderHttpException(HttpExceptionInterface $e)
|
||||
{
|
||||
$status = $e->getStatusCode();
|
||||
view()->replaceNamespace('errors', [
|
||||
resource_path('views/layouts/'.setting('general.theme', 'default').'/errors'),
|
||||
resource_path('views/errors'),
|
||||
__DIR__.'/views',
|
||||
]);
|
||||
|
||||
if (view()->exists("errors::{$status}")) {
|
||||
return response()->view("errors::{$status}", [
|
||||
'exception' => $e,
|
||||
'SKIN_NAME' => setting('general.theme', 'default'),
|
||||
], $status, $e->getHeaders());
|
||||
}
|
||||
|
||||
return $this->convertExceptionToResponse($e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignition error page integration
|
||||
*/
|
||||
|
||||
43
app/Exceptions/PilotIdNotFound.php
Normal file
43
app/Exceptions/PilotIdNotFound.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
class PilotIdNotFound extends AbstractHttpException
|
||||
{
|
||||
private $pilot_id;
|
||||
|
||||
public function __construct($pilot_id)
|
||||
{
|
||||
$this->pilot_id = $pilot_id;
|
||||
parent::__construct(
|
||||
404,
|
||||
'Pilot '.$pilot_id.' not found'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the RFC 7807 error type (without the URL root)
|
||||
*/
|
||||
public function getErrorType(): string
|
||||
{
|
||||
return 'pilot-id-not-found';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the detailed error string
|
||||
*/
|
||||
public function getErrorDetails(): string
|
||||
{
|
||||
return $this->getMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array with the error details, merged with the RFC7807 response
|
||||
*/
|
||||
public function getErrorMetadata(): array
|
||||
{
|
||||
return [
|
||||
'pilot_id' => $this->pilot_id,
|
||||
];
|
||||
}
|
||||
}
|
||||
43
app/Exceptions/Unauthorized.php
Normal file
43
app/Exceptions/Unauthorized.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Unauthorized extends AbstractHttpException
|
||||
{
|
||||
private $exception;
|
||||
|
||||
public function __construct(Exception $exception)
|
||||
{
|
||||
$this->exception = $exception;
|
||||
parent::__construct(
|
||||
403,
|
||||
$exception->getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the RFC 7807 error type (without the URL root)
|
||||
*/
|
||||
public function getErrorType(): string
|
||||
{
|
||||
return 'unauthorized';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the detailed error string
|
||||
*/
|
||||
public function getErrorDetails(): string
|
||||
{
|
||||
return $this->getMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array with the error details, merged with the RFC7807 response
|
||||
*/
|
||||
public function getErrorMetadata(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
46
app/Exceptions/UnknownPageType.php
Normal file
46
app/Exceptions/UnknownPageType.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use App\Models\Page;
|
||||
|
||||
class UnknownPageType extends AbstractHttpException
|
||||
{
|
||||
private $page;
|
||||
|
||||
public function __construct(Page $page)
|
||||
{
|
||||
$this->page = $page;
|
||||
parent::__construct(
|
||||
400,
|
||||
'Unknown page type "'.$page->type.'"'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the RFC 7807 error type (without the URL root)
|
||||
*/
|
||||
public function getErrorType(): string
|
||||
{
|
||||
return 'unknown-page-type';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the detailed error string
|
||||
*/
|
||||
public function getErrorDetails(): string
|
||||
{
|
||||
return $this->getMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array with the error details, merged with the RFC7807 response
|
||||
*/
|
||||
public function getErrorMetadata(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->page->id,
|
||||
'type' => $this->page->type,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,10 @@ use Illuminate\View\View;
|
||||
|
||||
class PageLinksComposer extends Composer
|
||||
{
|
||||
protected $pageRepo;
|
||||
private static $fields = ['id', 'name', 'slug', 'icon', 'type', 'link', 'new_window'];
|
||||
|
||||
/** @var \App\Repositories\PageRepository */
|
||||
private $pageRepo;
|
||||
|
||||
/**
|
||||
* PageLinksComposer constructor.
|
||||
@@ -28,13 +31,16 @@ class PageLinksComposer extends Composer
|
||||
public function compose(View $view)
|
||||
{
|
||||
try {
|
||||
$w = [
|
||||
'enabled' => true,
|
||||
];
|
||||
|
||||
// If not logged in, then only get the public pages
|
||||
$w = ['enabled' => true];
|
||||
if (!Auth::check()) {
|
||||
$w = ['public' => true];
|
||||
$w['public'] = true;
|
||||
}
|
||||
|
||||
$pages = $this->pageRepo->findWhere($w, ['id', 'name', 'slug', 'icon']);
|
||||
$pages = $this->pageRepo->findWhere($w, static::$fields);
|
||||
} catch (Exception $e) {
|
||||
$pages = [];
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Laracasts\Flash\Flash;
|
||||
use Nwidart\Modules\Facades\Module;
|
||||
|
||||
class MaintenanceController extends Controller
|
||||
{
|
||||
@@ -36,7 +37,7 @@ class MaintenanceController extends Controller
|
||||
return view('admin.maintenance.index', [
|
||||
'cron_path' => $this->cronSvc->getCronExecString(),
|
||||
'cron_problem_exists' => $this->cronSvc->cronProblemExists(),
|
||||
'new_version' => true, //$this->kvpRepo->get('new_version_available', false),
|
||||
'new_version' => $this->kvpRepo->get('new_version_available', false),
|
||||
'new_version_tag' => $this->kvpRepo->get('latest_version_tag'),
|
||||
]);
|
||||
}
|
||||
@@ -110,6 +111,10 @@ class MaintenanceController extends Controller
|
||||
{
|
||||
$new_version_tag = $this->kvpRepo->get('latest_version_tag');
|
||||
Log::info('Attempting to update to '.$new_version_tag);
|
||||
|
||||
$module = Module::find('updater');
|
||||
$module->enable();
|
||||
|
||||
return redirect('/update/downloader');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,11 +158,12 @@ class UserController extends Controller
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$user = $this->userRepo->findWithoutFail($id);
|
||||
$user = $this->userRepo
|
||||
->with(['fields', 'rank'])
|
||||
->findWithoutFail($id);
|
||||
|
||||
if (empty($user)) {
|
||||
Flash::error('User not found');
|
||||
|
||||
return redirect(route('admin.users.index'));
|
||||
}
|
||||
|
||||
|
||||
154
app/Http/Controllers/Admin/UserFieldController.php
Normal file
154
app/Http/Controllers/Admin/UserFieldController.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use App\Repositories\UserFieldRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use Laracasts\Flash\Flash;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
|
||||
class UserFieldController extends Controller
|
||||
{
|
||||
/** @var \App\Repositories\UserFieldRepository */
|
||||
private $userFieldRepo;
|
||||
|
||||
/**
|
||||
* @param UserFieldRepository $userFieldRepo
|
||||
*/
|
||||
public function __construct(UserFieldRepository $userFieldRepo)
|
||||
{
|
||||
$this->userFieldRepo = $userFieldRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the UserField.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws \Prettus\Repository\Exceptions\RepositoryException
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->userFieldRepo->pushCriteria(new RequestCriteria($request));
|
||||
$fields = $this->userFieldRepo->all();
|
||||
|
||||
return view('admin.userfields.index', ['fields' => $fields]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new UserField.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('admin.userfields.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created UserField in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$this->userFieldRepo->create($request->all());
|
||||
|
||||
Flash::success('Field added successfully.');
|
||||
return redirect(route('admin.userfields.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified UserField.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$field = $this->userFieldRepo->findWithoutFail($id);
|
||||
|
||||
if (empty($field)) {
|
||||
Flash::error('Flight field not found');
|
||||
return redirect(route('admin.userfields.index'));
|
||||
}
|
||||
|
||||
return view('admin.userfields.show', ['field' => $field]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified UserField.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$field = $this->userFieldRepo->findWithoutFail($id);
|
||||
|
||||
if (empty($field)) {
|
||||
Flash::error('Field not found');
|
||||
return redirect(route('admin.userfields.index'));
|
||||
}
|
||||
|
||||
return view('admin.userfields.edit', ['field' => $field]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified UserField in storage.
|
||||
*
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
$field = $this->userFieldRepo->findWithoutFail($id);
|
||||
|
||||
if (empty($field)) {
|
||||
Flash::error('UserField not found');
|
||||
return redirect(route('admin.userfields.index'));
|
||||
}
|
||||
|
||||
$this->userFieldRepo->update($request->all(), $id);
|
||||
|
||||
Flash::success('Field updated successfully.');
|
||||
return redirect(route('admin.userfields.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified UserField from storage.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$field = $this->userFieldRepo->findWithoutFail($id);
|
||||
if (empty($field)) {
|
||||
Flash::error('Field not found');
|
||||
return redirect(route('admin.userfields.index'));
|
||||
}
|
||||
|
||||
if ($this->userFieldRepo->isInUse($id)) {
|
||||
Flash::error('This field cannot be deleted, it is in use. Deactivate it instead');
|
||||
return redirect(route('admin.userfields.index'));
|
||||
}
|
||||
|
||||
$this->userFieldRepo->delete($id);
|
||||
|
||||
Flash::success('Field deleted successfully.');
|
||||
return redirect(route('admin.userfields.index'));
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use App\Events\AcarsUpdate;
|
||||
use App\Exceptions\PirepCancelled;
|
||||
use App\Http\Requests\Acars\EventRequest;
|
||||
use App\Http\Requests\Acars\LogRequest;
|
||||
@@ -198,6 +199,9 @@ class AcarsController extends Controller
|
||||
|
||||
$pirep->save();
|
||||
|
||||
// Post a new update for this ACARS position
|
||||
event(new AcarsUpdate($pirep, $pirep->position));
|
||||
|
||||
return $this->message($count.' positions added', $count);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,29 +78,32 @@ class FlightController extends Controller
|
||||
*/
|
||||
public function search(Request $request)
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = Auth::user();
|
||||
|
||||
$where = [
|
||||
'active' => true,
|
||||
'visible' => true,
|
||||
];
|
||||
|
||||
// Allow the option to bypass some of these restrictions for the searches
|
||||
if (!$request->filled('ignore_restrictions')
|
||||
|| $request->get('ignore_restrictions') === '0'
|
||||
) {
|
||||
if (!$request->filled('ignore_restrictions') || $request->get('ignore_restrictions') === '0') {
|
||||
if (setting('pilots.restrict_to_company')) {
|
||||
$where['airline_id'] = Auth::user()->airline_id;
|
||||
$where['airline_id'] = $user->airline_id;
|
||||
}
|
||||
|
||||
if (setting('pilots.only_flights_from_current')) {
|
||||
$where['dpt_airport_id'] = Auth::user()->curr_airport_id;
|
||||
$where['dpt_airport_id'] = $user->curr_airport_id;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$this->flightRepo->resetCriteria();
|
||||
$this->flightRepo->searchCriteria($request);
|
||||
$this->flightRepo->pushCriteria(new WhereCriteria($request, $where));
|
||||
$this->flightRepo->pushCriteria(new WhereCriteria($request, $where, [
|
||||
'airline' => ['active' => true],
|
||||
]));
|
||||
|
||||
$this->flightRepo->pushCriteria(new RequestCriteria($request));
|
||||
|
||||
$flights = $this->flightRepo
|
||||
|
||||
@@ -3,36 +3,98 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use App\Exceptions\PilotIdNotFound;
|
||||
use App\Models\Enums\UserState;
|
||||
use App\Services\UserService;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class LoginController
|
||||
*/
|
||||
class LoginController extends Controller
|
||||
{
|
||||
use AuthenticatesUsers;
|
||||
|
||||
protected $redirectTo = '/dashboard';
|
||||
|
||||
/** @var UserService */
|
||||
private $userSvc;
|
||||
|
||||
/** @var string */
|
||||
private $loginFieldValue;
|
||||
|
||||
/**
|
||||
* LoginController constructor.
|
||||
*
|
||||
* @param UserService $userSvc
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(UserService $userSvc)
|
||||
{
|
||||
$this->redirectTo = config('phpvms.login_redirect');
|
||||
$this->middleware('guest', ['except' => 'logout']);
|
||||
$this->userSvc = $userSvc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* Get the needed authorization credentials from the request.
|
||||
* Overriding the value from the trait
|
||||
*
|
||||
* @override
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function showLoginForm()
|
||||
protected function credentials(Request $request)
|
||||
{
|
||||
return view('auth/login');
|
||||
return [
|
||||
'email' => $this->loginFieldValue,
|
||||
'password' => $request->input('password'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the user login request.
|
||||
*
|
||||
* @override
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function validateLogin(Request $request)
|
||||
{
|
||||
$id_field = $request->input('email');
|
||||
$validations = ['required', 'string'];
|
||||
|
||||
/*
|
||||
* Trying to login by email or not?
|
||||
*
|
||||
* If not, run a validation rule which attempts to split the user by their VA and ID
|
||||
* Then inject that user's email into the request
|
||||
*/
|
||||
if (strpos($id_field, '@') !== false) {
|
||||
$validations[] = 'email';
|
||||
$this->loginFieldValue = $request->input('email');
|
||||
} else {
|
||||
$validations[] = function ($attr, $value, $fail) use ($request) {
|
||||
try {
|
||||
$user = $this->userSvc->findUserByPilotId($value);
|
||||
} catch (PilotIdNotFound $ex) {
|
||||
Log::warning('Error logging in, pilot_id not found, id='.$value);
|
||||
$fail('Pilot not found');
|
||||
return;
|
||||
}
|
||||
|
||||
$request->email = $user->email;
|
||||
$this->loginFieldValue = $user->email;
|
||||
};
|
||||
}
|
||||
|
||||
$request->validate([
|
||||
'email' => $validations,
|
||||
'password' => 'required|string',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,8 +109,7 @@ class LoginController extends Controller
|
||||
$user->last_ip = $request->ip();
|
||||
$user->save();
|
||||
|
||||
// TODO: How to handle ON_LEAVE?
|
||||
if ($user->state !== UserState::ACTIVE) {
|
||||
if ($user->state !== UserState::ACTIVE && $user->state !== UserState::ON_LEAVE) {
|
||||
Log::info('Trying to login '.$user->ident.', state '
|
||||
.UserState::label($user->state));
|
||||
|
||||
|
||||
@@ -3,19 +3,20 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use App\Http\Requests\CreateUserRequest;
|
||||
use App\Models\Enums\UserState;
|
||||
use App\Models\User;
|
||||
use App\Models\UserField;
|
||||
use App\Models\UserFieldValue;
|
||||
use App\Repositories\AirlineRepository;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Services\UserService;
|
||||
use App\Support\Countries;
|
||||
use App\Support\Timezonelist;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
@@ -61,12 +62,14 @@ class RegisterController extends Controller
|
||||
{
|
||||
$airports = $this->airportRepo->selectBoxList(false, setting('pilots.home_hubs_only'));
|
||||
$airlines = $this->airlineRepo->selectBoxList();
|
||||
$userFields = UserField::where(['show_on_registration' => true])->get();
|
||||
|
||||
return view('auth.register', [
|
||||
'airports' => $airports,
|
||||
'airlines' => $airlines,
|
||||
'countries' => Countries::getSelectList(),
|
||||
'timezones' => Timezonelist::toArray(),
|
||||
'airports' => $airports,
|
||||
'airlines' => $airlines,
|
||||
'countries' => Countries::getSelectList(),
|
||||
'timezones' => Timezonelist::toArray(),
|
||||
'userFields' => $userFields,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -81,13 +84,24 @@ class RegisterController extends Controller
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:users, email',
|
||||
'email' => 'required|email|max:255|unique:users,email',
|
||||
'airline_id' => 'required',
|
||||
'home_airport_id' => 'required',
|
||||
'password' => 'required|min:5|confirmed',
|
||||
'toc_accepted' => 'accepted',
|
||||
];
|
||||
|
||||
// Dynamically add the required fields
|
||||
$userFields = UserField::where([
|
||||
'show_on_registration' => true,
|
||||
'required' => true,
|
||||
'active' => true,
|
||||
])->get();
|
||||
|
||||
foreach ($userFields as $field) {
|
||||
$rules['field_'.$field->slug] = 'required';
|
||||
}
|
||||
|
||||
if (config('captcha.enabled')) {
|
||||
$rules['g-recaptcha-response'] = 'required|captcha';
|
||||
}
|
||||
@@ -119,6 +133,15 @@ class RegisterController extends Controller
|
||||
|
||||
Log::info('User registered: ', $user->toArray());
|
||||
|
||||
$userFields = UserField::all();
|
||||
foreach ($userFields as $field) {
|
||||
$field_name = 'field_'.$field->slug;
|
||||
UserFieldValue::updateOrCreate([
|
||||
'user_field_id' => $field->id,
|
||||
'user_id' => $user->id,
|
||||
], ['value' => $opts[$field_name]]);
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
@@ -131,8 +154,10 @@ class RegisterController extends Controller
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function register(CreateUserRequest $request)
|
||||
public function register(Request $request)
|
||||
{
|
||||
$this->validator($request->all())->validate();
|
||||
|
||||
$user = $this->create($request->all());
|
||||
if ($user->state === UserState::PENDING) {
|
||||
return view('auth.pending');
|
||||
|
||||
@@ -79,20 +79,26 @@ class FlightController extends Controller
|
||||
'visible' => true,
|
||||
];
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = Auth::user();
|
||||
|
||||
if (setting('pilots.restrict_to_company')) {
|
||||
$where['airline_id'] = Auth::user()->airline_id;
|
||||
$where['airline_id'] = $user->airline_id;
|
||||
}
|
||||
|
||||
// default restrictions on the flights shown. Handle search differently
|
||||
if (setting('pilots.only_flights_from_current')) {
|
||||
$where['dpt_airport_id'] = Auth::user()->curr_airport_id;
|
||||
$where['dpt_airport_id'] = $user->curr_airport_id;
|
||||
}
|
||||
|
||||
$this->flightRepo->resetCriteria();
|
||||
|
||||
try {
|
||||
$this->flightRepo->searchCriteria($request);
|
||||
$this->flightRepo->pushCriteria(new WhereCriteria($request, $where));
|
||||
$this->flightRepo->pushCriteria(new WhereCriteria($request, $where, [
|
||||
'airline' => ['active' => true],
|
||||
]));
|
||||
|
||||
$this->flightRepo->pushCriteria(new RequestCriteria($request));
|
||||
} catch (RepositoryException $e) {
|
||||
Log::emergency($e);
|
||||
|
||||
@@ -4,8 +4,10 @@ namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use App\Exceptions\PageNotFound;
|
||||
use App\Exceptions\Unauthorized;
|
||||
use App\Repositories\PageRepository;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class PageController extends Controller
|
||||
{
|
||||
@@ -28,11 +30,16 @@ class PageController extends Controller
|
||||
*/
|
||||
public function show($slug)
|
||||
{
|
||||
/** @var \App\Models\Page $page */
|
||||
$page = $this->pageRepo->findWhere(['slug' => $slug])->first();
|
||||
if (!$page) {
|
||||
throw new PageNotFound(new Exception('Page not found'));
|
||||
}
|
||||
|
||||
if (!$page->public && !Auth::check()) {
|
||||
throw new Unauthorized(new Exception('You must be logged in to view this page'));
|
||||
}
|
||||
|
||||
return view('pages.index', ['page' => $page]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Models\Enums\PirepState;
|
||||
use App\Models\Enums\PirepStatus;
|
||||
use App\Models\Pirep;
|
||||
use App\Models\SimBrief;
|
||||
use App\Models\User;
|
||||
use App\Repositories\AircraftRepository;
|
||||
use App\Repositories\AirlineRepository;
|
||||
use App\Repositories\AirportRepository;
|
||||
@@ -280,9 +281,11 @@ class PirepController extends Controller
|
||||
*/
|
||||
public function store(CreatePirepRequest $request)
|
||||
{
|
||||
// Create the main PIREP
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
|
||||
$pirep = new Pirep($request->post());
|
||||
$pirep->user_id = Auth::user()->id;
|
||||
$pirep->user_id = $user->id;
|
||||
|
||||
$attrs = $request->all();
|
||||
$attrs['submit'] = strtolower($attrs['submit']);
|
||||
@@ -290,8 +293,13 @@ class PirepController extends Controller
|
||||
if ($attrs['submit'] === 'submit') {
|
||||
// Are they allowed at this airport?
|
||||
if (setting('pilots.only_flights_from_current')
|
||||
&& Auth::user()->curr_airport_id !== $pirep->dpt_airport_id) {
|
||||
Log::info('Pilot '.Auth::user()->id.' not at departure airport, erroring out');
|
||||
&& $user->curr_airport_id !== $pirep->dpt_airport_id) {
|
||||
Log::info(
|
||||
'Pilot '.$user->id
|
||||
.' not at departure airport (curr='.$user->curr_airport_id
|
||||
.', dpt='.$pirep->dpt_airport_id.')'
|
||||
);
|
||||
|
||||
return $this->flashError(
|
||||
'You are currently not at the departure airport!',
|
||||
'frontend.pireps.create'
|
||||
@@ -300,8 +308,8 @@ class PirepController extends Controller
|
||||
|
||||
// Can they fly this aircraft?
|
||||
if (setting('pireps.restrict_aircraft_to_rank', false)
|
||||
&& !$this->userSvc->aircraftAllowed(Auth::user(), $pirep->aircraft_id)) {
|
||||
Log::info('Pilot '.Auth::user()->id.' not allowed to fly aircraft');
|
||||
&& !$this->userSvc->aircraftAllowed($user, $pirep->aircraft_id)) {
|
||||
Log::info('Pilot '.$user->id.' not allowed to fly aircraft');
|
||||
return $this->flashError(
|
||||
'You are not allowed to fly this aircraft!',
|
||||
'frontend.pireps.create'
|
||||
@@ -310,9 +318,20 @@ class PirepController extends Controller
|
||||
|
||||
// is the aircraft in the right place?
|
||||
/* @noinspection NotOptimalIfConditionsInspection */
|
||||
// Get the aircraft
|
||||
$aircraft = $this->aircraftRepo->findWithoutFail($pirep->aircraft_id);
|
||||
if ($aircraft === null) {
|
||||
Log::error('Aircraft for PIREP not found, id='.$pirep->aircraft_id);
|
||||
return $this->flashError(
|
||||
'The aircraft for the PIREP hasn\'t been found',
|
||||
'frontend.pireps.create'
|
||||
);
|
||||
}
|
||||
|
||||
if (setting('pireps.only_aircraft_at_dpt_airport')
|
||||
&& $pirep->aircraft_id !== $pirep->dpt_airport_id) {
|
||||
Log::info('Aircraft '.$pirep->aircraft_id.' not at departure airport '.$pirep->dpt_airport_id.', erroring out');
|
||||
&& $aircraft->airport_id !== $pirep->dpt_airport_id
|
||||
) {
|
||||
Log::info('Aircraft '.$pirep->aircraft_id.' not at departure airport (curr='.$pirep->aircraft->airport_id.', apt='.$pirep->dpt_airport_id.')');
|
||||
return $this->flashError(
|
||||
'This aircraft is not positioned at the departure airport!',
|
||||
'frontend.pireps.create'
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use App\Models\User;
|
||||
use App\Models\UserField;
|
||||
use App\Models\UserFieldValue;
|
||||
use App\Repositories\AirlineRepository;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
@@ -63,16 +65,22 @@ class ProfileController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
|
||||
if (setting('pilots.home_hubs_only')) {
|
||||
$airports = $this->airportRepo->findWhere(['hub' => true]);
|
||||
} else {
|
||||
$airports = $this->airportRepo->all();
|
||||
}
|
||||
|
||||
$userFields = $this->userRepo->getUserFields($user);
|
||||
|
||||
return view('profile.index', [
|
||||
'acars' => $this->acarsEnabled(),
|
||||
'user' => Auth::user(),
|
||||
'airports' => $airports,
|
||||
'acars' => $this->acarsEnabled(),
|
||||
'user' => $user,
|
||||
'airports' => $airports,
|
||||
'userFields' => $userFields,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -83,18 +91,22 @@ class ProfileController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$user = User::where('id', $id)->first();
|
||||
$user = User::with(['fields', 'fields.field'])
|
||||
->where('id', $id)
|
||||
->first();
|
||||
|
||||
if (empty($user)) {
|
||||
Flash::error('User not found!');
|
||||
|
||||
return redirect(route('frontend.dashboard.index'));
|
||||
}
|
||||
|
||||
$airports = $this->airportRepo->all();
|
||||
$userFields = $this->userRepo->getUserFields($user, true);
|
||||
|
||||
return view('profile.index', [
|
||||
'user' => $user,
|
||||
'airports' => $airports,
|
||||
'user' => $user,
|
||||
'userFields' => $userFields,
|
||||
'airports' => $airports,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -109,22 +121,27 @@ class ProfileController extends Controller
|
||||
*/
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$user = User::where('id', Auth::user()->id)->first();
|
||||
/** @var \App\Models\User $user */
|
||||
$user = User::with(['fields', 'fields.field'])
|
||||
->where('id', Auth::user()->id)
|
||||
->first();
|
||||
|
||||
if (empty($user)) {
|
||||
Flash::error('User not found!');
|
||||
|
||||
return redirect(route('frontend.dashboard.index'));
|
||||
}
|
||||
|
||||
$airlines = $this->airlineRepo->selectBoxList();
|
||||
$airports = $this->airportRepo->selectBoxList(false, setting('pilots.home_hubs_only'));
|
||||
$userFields = $this->userRepo->getUserFields($user, false);
|
||||
|
||||
return view('profile.edit', [
|
||||
'user' => $user,
|
||||
'airlines' => $airlines,
|
||||
'airports' => $airports,
|
||||
'countries' => Countries::getSelectList(),
|
||||
'timezones' => Timezonelist::toArray(),
|
||||
'user' => $user,
|
||||
'airlines' => $airlines,
|
||||
'airports' => $airports,
|
||||
'countries' => Countries::getSelectList(),
|
||||
'timezones' => Timezonelist::toArray(),
|
||||
'userFields' => $userFields,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -140,13 +157,20 @@ class ProfileController extends Controller
|
||||
$id = Auth::user()->id;
|
||||
$user = $this->userRepo->findWithoutFail($id);
|
||||
|
||||
$validator = Validator::make($request->toArray(), [
|
||||
$rules = [
|
||||
'name' => 'required',
|
||||
'email' => 'required|unique:users,email,'.$id,
|
||||
'airline_id' => 'required',
|
||||
'password' => 'confirmed',
|
||||
'avatar' => 'nullable|mimes:jpeg,png,jpg',
|
||||
]);
|
||||
];
|
||||
|
||||
$userFields = UserField::where(['show_on_registration' => true, 'required' => true])->get();
|
||||
foreach ($userFields as $field) {
|
||||
$rules['field_'.$field->slug] = 'required';
|
||||
}
|
||||
|
||||
$validator = Validator::make($request->toArray(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
Log::info('validator failed for user '.$user->ident);
|
||||
@@ -167,6 +191,7 @@ class ProfileController extends Controller
|
||||
if (isset($req_data['avatar']) !== null) {
|
||||
Storage::delete($user->avatar);
|
||||
}
|
||||
|
||||
if ($request->hasFile('avatar')) {
|
||||
$avatar = $request->file('avatar');
|
||||
$file_name = $user->ident.'.'.$avatar->getClientOriginalExtension();
|
||||
@@ -190,6 +215,16 @@ class ProfileController extends Controller
|
||||
|
||||
$this->userRepo->update($req_data, $id);
|
||||
|
||||
// Save all of the user fields
|
||||
$userFields = UserField::all();
|
||||
foreach ($userFields as $field) {
|
||||
$field_name = 'field_'.$field->slug;
|
||||
UserFieldValue::updateOrCreate([
|
||||
'user_field_id' => $field->id,
|
||||
'user_id' => $id,
|
||||
], ['value' => $request->get($field_name)]);
|
||||
}
|
||||
|
||||
Flash::success('Profile updated successfully!');
|
||||
|
||||
return redirect(route('frontend.profile.index'));
|
||||
|
||||
@@ -45,6 +45,7 @@ class Kernel extends HttpKernel
|
||||
ShareErrorsFromSession::class,
|
||||
// VerifyCsrfToken::class,
|
||||
SubstituteBindings::class,
|
||||
SetActiveTheme::class,
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@@ -13,8 +13,44 @@ use Illuminate\Support\Facades\Log;
|
||||
*/
|
||||
class SetActiveTheme implements Middleware
|
||||
{
|
||||
private static $skip = [
|
||||
'admin',
|
||||
'admin/*',
|
||||
'api',
|
||||
'api/*',
|
||||
'importer',
|
||||
'importer/*',
|
||||
'install',
|
||||
'install/*',
|
||||
'update',
|
||||
'update/*',
|
||||
];
|
||||
|
||||
/**
|
||||
* Handle the request
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$this->setTheme($request);
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the theme for the current middleware
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*/
|
||||
public function setTheme(Request $request)
|
||||
{
|
||||
if ($request->is(self::$skip)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$theme = setting('general.theme');
|
||||
} catch (\Exception $e) {
|
||||
@@ -25,7 +61,5 @@ class SetActiveTheme implements Middleware
|
||||
if (!empty($theme)) {
|
||||
Theme::set($theme);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class UpdatePageRequest extends FormRequest
|
||||
'required',
|
||||
Rule::unique('pages')->ignore($this->id, 'id'),
|
||||
],
|
||||
'body' => 'required',
|
||||
'body' => 'nullable',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\Resource;
|
||||
use App\Contracts\Resource;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\SimBrief
|
||||
|
||||
@@ -16,6 +16,8 @@ use Carbon\Carbon;
|
||||
* @property string icao
|
||||
* @property string registration
|
||||
* @property int flight_time
|
||||
* @property float mtow
|
||||
* @property float zfw
|
||||
* @property string hex_code
|
||||
* @property Airport airport
|
||||
* @property Subfleet subfleet
|
||||
@@ -39,6 +41,7 @@ class Aircraft extends Model
|
||||
'registration',
|
||||
'hex_code',
|
||||
'flight_time',
|
||||
'mtow',
|
||||
'zfw',
|
||||
'status',
|
||||
'state',
|
||||
@@ -49,6 +52,7 @@ class Aircraft extends Model
|
||||
*/
|
||||
protected $casts = [
|
||||
'subfleet_id' => 'integer',
|
||||
'mtow' => 'float',
|
||||
'zfw' => 'float',
|
||||
'flight_time' => 'float',
|
||||
'state' => 'integer',
|
||||
@@ -62,6 +66,8 @@ class Aircraft extends Model
|
||||
'name' => 'required',
|
||||
'status' => 'required',
|
||||
'registration' => 'required',
|
||||
'mtow' => 'nullable|numeric',
|
||||
'zfw' => 'nullable|numeric',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Enums;
|
||||
|
||||
use App\Contracts\Enum;
|
||||
|
||||
class AnalyticsDimensions extends Enum
|
||||
{
|
||||
public const PHP_VERSION = 1;
|
||||
public const DATABASE_VERSION = 2;
|
||||
public const PHPVMS_VERSION = 3;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Enums;
|
||||
|
||||
use App\Contracts\Enum;
|
||||
|
||||
/**
|
||||
* Metrics IDs used in Google Analytics
|
||||
*/
|
||||
class AnalyticsMetrics extends Enum
|
||||
{
|
||||
// Track the lookup time for airports from vaCentral
|
||||
public const AIRPORT_LOOKUP_TIME = 1;
|
||||
}
|
||||
@@ -6,6 +6,11 @@ use App\Contracts\Enum;
|
||||
|
||||
class PageType extends Enum
|
||||
{
|
||||
public const HTML = 0;
|
||||
public const MARKDOWN = 1;
|
||||
public const PAGE = 0;
|
||||
public const LINK = 1;
|
||||
|
||||
public static $labels = [
|
||||
self::PAGE => 'Page',
|
||||
self::LINK => 'Link',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property string $disk
|
||||
* @property string $path
|
||||
* @property bool $public
|
||||
* @property int $download_count
|
||||
* @property string $url
|
||||
* @property string $filename
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property string $disk
|
||||
* @property string $path
|
||||
* @property bool $public
|
||||
* @property int $download_count
|
||||
* @property string $url
|
||||
* @property string $filename
|
||||
*/
|
||||
class File extends Model
|
||||
{
|
||||
|
||||
@@ -14,11 +14,11 @@ use Carbon\Carbon;
|
||||
* Holds various journals, depending on the morphed_type and morphed_id columns
|
||||
*
|
||||
* @property mixed id
|
||||
* @property Money $balance
|
||||
* @property string $currency
|
||||
* @property Carbon $updated_at
|
||||
* @property Carbon $post_date
|
||||
* @property Carbon $created_at
|
||||
* @property Money $balance
|
||||
* @property string $currency
|
||||
* @property Carbon $updated_at
|
||||
* @property Carbon $post_date
|
||||
* @property Carbon $created_at
|
||||
* @property \App\Models\Enums\JournalType type
|
||||
* @property mixed morphed_type
|
||||
* @property mixed morphed_id
|
||||
|
||||
@@ -13,11 +13,11 @@ use Carbon\Carbon;
|
||||
/**
|
||||
* Class Ledger
|
||||
*
|
||||
* @property Money $balance
|
||||
* @property string $currency
|
||||
* @property Carbon $updated_at
|
||||
* @property Carbon $post_date
|
||||
* @property Carbon $created_at
|
||||
* @property Money $balance
|
||||
* @property string $currency
|
||||
* @property Carbon $updated_at
|
||||
* @property Carbon $post_date
|
||||
* @property Carbon $created_at
|
||||
*/
|
||||
class Ledger extends Model
|
||||
{
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Contracts\Model;
|
||||
use App\Exceptions\UnknownPageType;
|
||||
use App\Models\Enums\PageType;
|
||||
|
||||
/**
|
||||
* @property int id
|
||||
@@ -12,7 +14,9 @@ use App\Contracts\Model;
|
||||
* @property int type
|
||||
* @property bool public
|
||||
* @property bool enabled
|
||||
* @property bool new_window
|
||||
* @property string body
|
||||
* @property string link
|
||||
*/
|
||||
class Page extends Model
|
||||
{
|
||||
@@ -25,17 +29,39 @@ class Page extends Model
|
||||
'icon',
|
||||
'public',
|
||||
'body',
|
||||
'link',
|
||||
'enabled',
|
||||
'new_window',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'type' => 'integer',
|
||||
'public' => 'boolean',
|
||||
'enabled' => 'boolean',
|
||||
'type' => 'integer',
|
||||
'public' => 'boolean',
|
||||
'enabled' => 'boolean',
|
||||
'new_window' => 'boolean',
|
||||
];
|
||||
|
||||
public static $rules = [
|
||||
'name' => 'required|unique:pages,name',
|
||||
'body' => 'required',
|
||||
'body' => 'nullable',
|
||||
'type' => 'required',
|
||||
];
|
||||
|
||||
/**
|
||||
* Return the full URL to this page; determines if it's internal or external
|
||||
*
|
||||
* @throws \App\Exceptions\UnknownPageType
|
||||
*/
|
||||
public function getUrlAttribute(): string
|
||||
{
|
||||
if ($this->type === PageType::PAGE) {
|
||||
return url(route('frontend.pages.show', ['slug' => $this->slug]));
|
||||
}
|
||||
|
||||
if ($this->type === PageType::LINK) {
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
throw new UnknownPageType($this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ use Illuminate\Support\Collection;
|
||||
* @property User user
|
||||
* @property Flight|null flight
|
||||
* @property Collection fields
|
||||
* @property int status
|
||||
* @property string status
|
||||
* @property bool state
|
||||
* @property string source
|
||||
* @property Carbon submitted_at
|
||||
|
||||
@@ -6,10 +6,10 @@ use App\Contracts\Model;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* @property string $id The Simbrief OFP ID
|
||||
* @property int $user_id The user that generated this
|
||||
* @property string $flight_id Optional, if attached to a flight, removed if attached to PIREP
|
||||
* @property string $pirep_id Optional, if attached to a PIREP, removed if attached to flight
|
||||
* @property string $id The Simbrief OFP ID
|
||||
* @property int $user_id The user that generated this
|
||||
* @property string $flight_id Optional, if attached to a flight, removed if attached to PIREP
|
||||
* @property string $pirep_id Optional, if attached to a PIREP, removed if attached to flight
|
||||
* @property string $acars_xml
|
||||
* @property string $ofp_xml
|
||||
* @property string $ofp_html
|
||||
|
||||
@@ -33,6 +33,8 @@ class Subfleet extends Model
|
||||
'name',
|
||||
'turn_time',
|
||||
'fuel_type',
|
||||
'cost_block_hour',
|
||||
'cost_delay_minute',
|
||||
'ground_handling_multiplier',
|
||||
'cargo_capacity',
|
||||
'fuel_capacity',
|
||||
|
||||
@@ -10,32 +10,33 @@ use Illuminate\Notifications\Notifiable;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
|
||||
/**
|
||||
* @property int id
|
||||
* @property int pilot_id
|
||||
* @property int airline_id
|
||||
* @property string name
|
||||
* @property string name_private Only first name, rest are initials
|
||||
* @property string email
|
||||
* @property string password
|
||||
* @property string api_key
|
||||
* @property mixed timezone
|
||||
* @property string ident
|
||||
* @property string curr_airport_id
|
||||
* @property string home_airport_id
|
||||
* @property string avatar
|
||||
* @property Airline airline
|
||||
* @property Flight[] flights
|
||||
* @property int flight_time
|
||||
* @property int transfer_time
|
||||
* @property string remember_token
|
||||
* @property \Carbon\Carbon created_at
|
||||
* @property \Carbon\Carbon updated_at
|
||||
* @property Rank rank
|
||||
* @property Journal journal
|
||||
* @property int rank_id
|
||||
* @property int state
|
||||
* @property bool opt_in
|
||||
* @property string last_pirep_id
|
||||
* @property int id
|
||||
* @property int pilot_id
|
||||
* @property int airline_id
|
||||
* @property string name
|
||||
* @property string name_private Only first name, rest are initials
|
||||
* @property string email
|
||||
* @property string password
|
||||
* @property string api_key
|
||||
* @property mixed timezone
|
||||
* @property string ident
|
||||
* @property string curr_airport_id
|
||||
* @property string home_airport_id
|
||||
* @property string avatar
|
||||
* @property Airline airline
|
||||
* @property Flight[] flights
|
||||
* @property int flight_time
|
||||
* @property int transfer_time
|
||||
* @property string remember_token
|
||||
* @property \Carbon\Carbon created_at
|
||||
* @property \Carbon\Carbon updated_at
|
||||
* @property Rank rank
|
||||
* @property Journal journal
|
||||
* @property int rank_id
|
||||
* @property int state
|
||||
* @property bool opt_in
|
||||
* @property string last_pirep_id
|
||||
* @property UserFieldValue[] fields
|
||||
*
|
||||
* @mixin \Illuminate\Database\Eloquent\Builder
|
||||
* @mixin \Illuminate\Notifications\Notifiable
|
||||
@@ -212,6 +213,16 @@ class User extends Authenticatable
|
||||
return $this->hasMany(UserAward::class, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* The bid rows
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function bids()
|
||||
{
|
||||
return $this->hasMany(Bid::class, 'user_id');
|
||||
}
|
||||
|
||||
public function home_airport()
|
||||
{
|
||||
return $this->belongsTo(Airport::class, 'home_airport_id');
|
||||
@@ -227,22 +238,9 @@ class User extends Authenticatable
|
||||
return $this->belongsTo(Pirep::class, 'last_pirep_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* These are the flights they've bid on
|
||||
*/
|
||||
// public function flights()
|
||||
// {
|
||||
// return $this->belongsToMany(Flight::class, 'bids');
|
||||
// }
|
||||
|
||||
/**
|
||||
* The bid rows
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function bids()
|
||||
public function fields()
|
||||
{
|
||||
return $this->hasMany(Bid::class, 'user_id');
|
||||
return $this->hasMany(UserFieldValue::class, 'user_id');
|
||||
}
|
||||
|
||||
public function pireps()
|
||||
|
||||
49
app/Models/UserField.php
Normal file
49
app/Models/UserField.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Contracts\Model;
|
||||
|
||||
/**
|
||||
* @property string name
|
||||
* @property string slug
|
||||
* @property string value Only set if "squashed"
|
||||
* @property bool show_on_registration
|
||||
* @property bool required
|
||||
* @property bool private
|
||||
*/
|
||||
class UserField extends Model
|
||||
{
|
||||
public $table = 'user_fields';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
'show_on_registration', // Show on the registration form?
|
||||
'required', // Required to be filled out in registration?
|
||||
'private', // Whether this is shown on the user's public profile
|
||||
'active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'show_on_registration' => 'boolean',
|
||||
'required' => 'boolean',
|
||||
'private' => 'boolean',
|
||||
'active' => 'boolean',
|
||||
];
|
||||
|
||||
public static $rules = [
|
||||
'name' => 'required',
|
||||
'description' => 'nullable',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the slug so we can use it in forms
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSlugAttribute(): string
|
||||
{
|
||||
return str_slug($this->name, '_');
|
||||
}
|
||||
}
|
||||
37
app/Models/UserFieldValue.php
Normal file
37
app/Models/UserFieldValue.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Contracts\Model;
|
||||
|
||||
/**
|
||||
* @property string name
|
||||
* @property string value
|
||||
* @property UserField field
|
||||
* @property User user
|
||||
*/
|
||||
class UserFieldValue extends Model
|
||||
{
|
||||
public $table = 'user_field_values';
|
||||
|
||||
protected $fillable = [
|
||||
'user_field_id',
|
||||
'user_id',
|
||||
'value',
|
||||
];
|
||||
|
||||
public static $rules = [];
|
||||
|
||||
/**
|
||||
* Foreign Keys
|
||||
*/
|
||||
public function field()
|
||||
{
|
||||
return $this->belongsTo(UserField::class, 'user_field_id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ trait MailChannel
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage())
|
||||
->from(config('mail.from.address', 'no-reply@phpvms.net'))
|
||||
->from(config('mail.from.address', 'no-reply@phpvms.net'), config('mail.from.name'))
|
||||
->subject($this->mailSubject)
|
||||
->markdown($this->mailTemplate, $this->mailTemplateArgs);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use App\Notifications\Messages\UserPending;
|
||||
use App\Notifications\Messages\UserRejected;
|
||||
use App\Notifications\Notifiables\Broadcast;
|
||||
use Exception;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
@@ -27,6 +28,7 @@ class EventHandler extends Listener
|
||||
private static $broadcastNotifyable;
|
||||
|
||||
public static $callbacks = [
|
||||
NewsAdded::class => 'onNewsAdded',
|
||||
PirepAccepted::class => 'onPirepAccepted',
|
||||
PirepFiled::class => 'onPirepFile',
|
||||
PirepRejected::class => 'onPirepRejected',
|
||||
@@ -42,7 +44,7 @@ class EventHandler extends Listener
|
||||
/**
|
||||
* Send a notification to all of the admins
|
||||
*
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @param \App\Contracts\Notification $notification
|
||||
*/
|
||||
protected function notifyAdmins($notification)
|
||||
{
|
||||
@@ -56,8 +58,8 @@ class EventHandler extends Listener
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @param User $user
|
||||
* @param \App\Contracts\Notification $notification
|
||||
*/
|
||||
protected function notifyUser($user, $notification)
|
||||
{
|
||||
@@ -69,13 +71,25 @@ class EventHandler extends Listener
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a notification to all users
|
||||
* Send a notification to all users. Also can specify if a particular notification
|
||||
* requires an opt-in
|
||||
*
|
||||
* @param $notification
|
||||
* @param \App\Contracts\Notification $notification
|
||||
*/
|
||||
protected function notifyAllUsers($notification)
|
||||
protected function notifyAllUsers(\App\Contracts\Notification $notification)
|
||||
{
|
||||
$users = User::all()->get();
|
||||
$where = [];
|
||||
if ($notification->requires_opt_in === true) { // If the opt-in is required
|
||||
$where['opt_in'] = true;
|
||||
}
|
||||
|
||||
/** @var Collection $users */
|
||||
$users = User::where($where)->get();
|
||||
if (empty($users) || $users->count() === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log::info('Sending notification to '.$users->count().' users');
|
||||
|
||||
try {
|
||||
Notification::send($users, $notification);
|
||||
@@ -164,7 +178,7 @@ class EventHandler extends Listener
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify all users of a news event
|
||||
* Notify all users of a news event, but only the users which have opted in
|
||||
*
|
||||
* @param \App\Events\NewsAdded $event
|
||||
*/
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Notifications\Messages;
|
||||
|
||||
use App\Contracts\Notification;
|
||||
use App\Models\User;
|
||||
use App\Notifications\BaseNotification;
|
||||
use App\Notifications\Channels\MailChannel;
|
||||
|
||||
class AdminUserRegistered extends BaseNotification
|
||||
class AdminUserRegistered extends Notification
|
||||
{
|
||||
use MailChannel;
|
||||
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
|
||||
namespace App\Notifications\Messages;
|
||||
|
||||
use App\Contracts\Notification;
|
||||
use App\Models\News;
|
||||
use App\Notifications\BaseNotification;
|
||||
use App\Notifications\Channels\MailChannel;
|
||||
|
||||
class NewsAdded extends BaseNotification
|
||||
class NewsAdded extends Notification
|
||||
{
|
||||
use MailChannel;
|
||||
|
||||
public $channels = ['mail'];
|
||||
public $requires_opt_in = true;
|
||||
|
||||
private $news;
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\Notifications\Messages;
|
||||
|
||||
use App\Contracts\Notification;
|
||||
use App\Models\Pirep;
|
||||
use App\Notifications\BaseNotification;
|
||||
use App\Notifications\Channels\MailChannel;
|
||||
|
||||
/**
|
||||
* Send the PIREP accepted message to a particular user
|
||||
*/
|
||||
class PirepAccepted extends BaseNotification
|
||||
class PirepAccepted extends Notification
|
||||
{
|
||||
use MailChannel;
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Notifications\Messages;
|
||||
|
||||
use App\Contracts\Notification;
|
||||
use App\Models\Pirep;
|
||||
use App\Notifications\BaseNotification;
|
||||
use App\Notifications\Channels\MailChannel;
|
||||
|
||||
class PirepRejected extends BaseNotification
|
||||
class PirepRejected extends Notification
|
||||
{
|
||||
use MailChannel;
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Notifications\Messages;
|
||||
|
||||
use App\Contracts\Notification;
|
||||
use App\Models\Pirep;
|
||||
use App\Notifications\BaseNotification;
|
||||
use App\Notifications\Channels\MailChannel;
|
||||
|
||||
class PirepSubmitted extends BaseNotification
|
||||
class PirepSubmitted extends Notification
|
||||
{
|
||||
use MailChannel;
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Notifications\Messages;
|
||||
|
||||
use App\Contracts\Notification;
|
||||
use App\Models\User;
|
||||
use App\Notifications\BaseNotification;
|
||||
use App\Notifications\Channels\MailChannel;
|
||||
|
||||
class UserPending extends BaseNotification
|
||||
class UserPending extends Notification
|
||||
{
|
||||
use MailChannel;
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Notifications\Messages;
|
||||
|
||||
use App\Contracts\Notification;
|
||||
use App\Models\User;
|
||||
use App\Notifications\BaseNotification;
|
||||
use App\Notifications\Channels\MailChannel;
|
||||
|
||||
class UserRegistered extends BaseNotification
|
||||
class UserRegistered extends Notification
|
||||
{
|
||||
use MailChannel;
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Notifications\Messages;
|
||||
|
||||
use App\Contracts\Notification;
|
||||
use App\Models\User;
|
||||
use App\Notifications\BaseNotification;
|
||||
use App\Notifications\Channels\MailChannel;
|
||||
|
||||
class UserRejected extends BaseNotification
|
||||
class UserRejected extends Notification
|
||||
{
|
||||
use MailChannel;
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ class BindServiceProviders extends ServiceProvider
|
||||
IVaCentral::class,
|
||||
function ($app) {
|
||||
$client = new VaCentral();
|
||||
$client->setVaCentralUrl(config('vacentral.api_url'));
|
||||
|
||||
// Set API if exists
|
||||
if (filled(config('vacentral.api_key'))) {
|
||||
|
||||
@@ -38,7 +38,6 @@ class EventServiceProvider extends ServiceProvider
|
||||
|
||||
UpdateAvailable::class => [],
|
||||
UpdateSucceeded::class => [],
|
||||
|
||||
];
|
||||
|
||||
protected $subscribe = [
|
||||
|
||||
@@ -39,7 +39,7 @@ class RouteServiceProvider extends ServiceProvider
|
||||
private function mapWebRoutes()
|
||||
{
|
||||
Route::group([
|
||||
'middleware' => ['web', 'theme'],
|
||||
'middleware' => ['web'],
|
||||
'namespace' => $this->namespace,
|
||||
], function ($router) {
|
||||
Route::group([
|
||||
@@ -60,8 +60,6 @@ class RouteServiceProvider extends ServiceProvider
|
||||
Route::get('flights/search', 'FlightController@search')->name('flights.search');
|
||||
Route::resource('flights', 'FlightController');
|
||||
|
||||
Route::get('p/{slug}', 'PageController@show')->name('pages.show');
|
||||
|
||||
Route::get('pireps/fares', 'PirepController@fares');
|
||||
Route::post('pireps/{id}/submit', 'PirepController@submit')->name('pireps.submit');
|
||||
|
||||
@@ -95,15 +93,18 @@ class RouteServiceProvider extends ServiceProvider
|
||||
Route::get('users/{id}', 'ProfileController@show')->name('users.show.public');
|
||||
Route::get('pilots/{id}', 'ProfileController@show')->name('pilots.show.public');
|
||||
|
||||
Route::get('p/{id}', 'ProfileController@show')->name('profile.show.public');
|
||||
Route::get('page/{slug}', 'PageController@show')->name('pages.show');
|
||||
|
||||
Route::get('profile/{id}', 'ProfileController@show')->name('profile.show.public');
|
||||
|
||||
Route::get('users', 'UserController@index')->name('users.index');
|
||||
Route::get('pilots', 'UserController@index')->name('pilots.index');
|
||||
|
||||
Route::get('livemap', 'LiveMapController@index')->name('livemap.index');
|
||||
});
|
||||
|
||||
Route::get('/logout', 'Auth\LoginController@logout')->name('auth.logout');
|
||||
Auth::routes(['verify' => true]);
|
||||
Route::get('/logout', 'Auth\LoginController@logout')->name('logout');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -261,10 +262,10 @@ class RouteServiceProvider extends ServiceProvider
|
||||
Route::resource('flightfields', 'FlightFieldController')
|
||||
->middleware('ability:admin,flights');
|
||||
|
||||
// pirep related routes
|
||||
Route::get('pireps/fares', 'PirepController@fares')
|
||||
->middleware('ability:admin,pireps');
|
||||
Route::resource('userfields', 'UserFieldController')->middleware('ability:admin,users');
|
||||
|
||||
// pirep related routes
|
||||
Route::get('pireps/fares', 'PirepController@fares')->middleware('ability:admin,pireps');
|
||||
Route::get('pireps/pending', 'PirepController@pending')
|
||||
->middleware('ability:admin,pireps');
|
||||
|
||||
|
||||
@@ -27,14 +27,19 @@ class AirlineRepository extends Repository implements CacheableInterface
|
||||
/**
|
||||
* Return the list of airline formatted for a select box
|
||||
*
|
||||
* @param mixed $add_blank
|
||||
* @param bool $add_blank
|
||||
* @param bool $only_active
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function selectBoxList($add_blank = false): array
|
||||
public function selectBoxList($add_blank = false, $only_active = true): array
|
||||
{
|
||||
$retval = [];
|
||||
$items = $this->all();
|
||||
$where = [
|
||||
'active' => $only_active,
|
||||
];
|
||||
|
||||
$items = $this->findWhere($where);
|
||||
|
||||
if ($add_blank) {
|
||||
$retval[''] = '';
|
||||
|
||||
@@ -24,13 +24,14 @@ class ExpenseRepository extends Repository implements CacheableInterface
|
||||
* Get all of the expenses for a given type, and also
|
||||
* include expenses for a given airline ID
|
||||
*
|
||||
* @param $type
|
||||
* @param null $airline_id
|
||||
* @param null $ref_model
|
||||
* @param $type
|
||||
* @param int $airline_id
|
||||
* @param string $ref_model
|
||||
* @param mixed $ref_model_id
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllForType($type, $airline_id = null, $ref_model = null)
|
||||
public function getAllForType($type, $airline_id = null, $ref_model = null, $ref_model_id = null)
|
||||
{
|
||||
$where = [
|
||||
'type' => $type,
|
||||
@@ -47,6 +48,10 @@ class ExpenseRepository extends Repository implements CacheableInterface
|
||||
if ($ref_model) {
|
||||
$where['ref_model'] = $ref_model_type;
|
||||
}
|
||||
|
||||
if ($ref_model_id) {
|
||||
$where['ref_model_id'] = $ref_model_id;
|
||||
}
|
||||
}
|
||||
|
||||
$expenses = $this->findWhere($where);
|
||||
|
||||
@@ -7,9 +7,6 @@ use App\Models\Enums\PirepState;
|
||||
use App\Models\Pirep;
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Class PirepRepository
|
||||
*/
|
||||
class PirepRepository extends Repository
|
||||
{
|
||||
protected $fieldSearchable = [
|
||||
|
||||
32
app/Repositories/UserFieldRepository.php
Normal file
32
app/Repositories/UserFieldRepository.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Contracts\Repository;
|
||||
use App\Models\UserField;
|
||||
use App\Models\UserFieldValue;
|
||||
|
||||
class UserFieldRepository extends Repository
|
||||
{
|
||||
protected $fieldSearchable = [
|
||||
'name' => 'like',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function model(): string
|
||||
{
|
||||
return UserField::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether or not this field is in use by a value
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public function isInUse($id): bool
|
||||
{
|
||||
return UserFieldValue::where(['user_field_id' => $id])->exists();
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,11 @@ namespace App\Repositories;
|
||||
use App\Contracts\Repository;
|
||||
use App\Models\Enums\UserState;
|
||||
use App\Models\User;
|
||||
use App\Models\UserField;
|
||||
use App\Repositories\Criteria\WhereCriteria;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class UserRepository
|
||||
*/
|
||||
class UserRepository extends Repository
|
||||
{
|
||||
protected $fieldSearchable = [
|
||||
@@ -29,6 +28,28 @@ class UserRepository extends Repository
|
||||
return User::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the fields which has the mapped values
|
||||
*
|
||||
* @param User $user
|
||||
* @param bool $only_public_fields Only include the user's public fields
|
||||
*
|
||||
* @return \App\Models\UserField[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection
|
||||
*/
|
||||
public function getUserFields(User $user, $only_public_fields = true): Collection
|
||||
{
|
||||
$fields = UserField::where(['private' => !$only_public_fields])->get();
|
||||
return $fields->map(function ($field, $_) use ($user) {
|
||||
foreach ($user->fields as $userFieldValue) {
|
||||
if ($userFieldValue->field->slug === $field->slug) {
|
||||
$field->value = $userFieldValue->value;
|
||||
}
|
||||
}
|
||||
|
||||
return $field;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of PIREPs that are pending
|
||||
*
|
||||
@@ -40,11 +61,9 @@ class UserRepository extends Repository
|
||||
'state' => UserState::PENDING,
|
||||
];
|
||||
|
||||
$users = $this->orderBy('created_at', 'desc')
|
||||
return $this->orderBy('created_at', 'desc')
|
||||
->findWhere($where, ['id'])
|
||||
->count();
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user