Compare commits

...

5 Commits

Author SHA1 Message Date
Gogs 3d657ecfd8 Composer.json 2021-07-25 17:32:06 +02:00
Gogs b28e53d333 Subscription testing 2021-07-25 01:06:13 +02:00
Gogs d8b5904ef5 format 2021-06-16 22:14:17 +02:00
Gogs 9bdf500359 Switch fields 2021-06-16 22:07:08 +02:00
Gogs 4375975002 Deferred Bindings 2021-06-14 16:07:36 +02:00
6 changed files with 123 additions and 2 deletions
+79
View File
@@ -0,0 +1,79 @@
<?php namespace GermanAirlinesVa\Fleet\Classes;
use GermanAirlinesVa\Fleet\Models\Aircraft as Model;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use GraphQL\Type\Definition\ResolveInfo;
use Nuwave\Lighthouse\Subscriptions\Subscriber;
use Nuwave\Lighthouse\Schema\Types\GraphQLSubscription;
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;
class Aircraft extends GraphQLSubscription
{
/**
* Check if subscriber is allowed to listen to the subscription.
*
* @param \Nuwave\Lighthouse\Subscriptions\Subscriber $subscriber
* @param \Illuminate\Http\Request $request
* @return bool
*/
public function authorize(Subscriber $subscriber, Request $request): bool
{
return true;
}
/**
* Filter which subscribers should receive the subscription.
*
* @param \Nuwave\Lighthouse\Subscriptions\Subscriber $subscriber
* @param mixed $root
* @return bool
*/
public function filter(Subscriber $subscriber, $root): bool
{
return true;
}
/**
* Encode topic name.
*
* @param \Nuwave\Lighthouse\Subscriptions\Subscriber $subscriber
* @param string $fieldName
* @return string
*/
public function encodeTopic(Subscriber $subscriber, string $fieldName): string
{
// Create a unique topic name based on the `author` argument
return Str::snake($fieldName);
}
/**
* Decode topic name.
*
* @param string $fieldName
* @param \App\Post $root
* @return string
*/
public function decodeTopic(string $fieldName, $root): string
{
return Str::snake($fieldName);
}
/**
* Resolve the subscription.
*
* @param \App\Post $root
* @param array<string, mixed> $args
* @param \Nuwave\Lighthouse\Support\Contracts\GraphQLContext $context
* @param \GraphQL\Type\Definition\ResolveInfo $resolveInfo
* @return mixed
*/
public function resolve($root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo): Model
{
// Optionally manipulate the `$root` item before it gets broadcasted to
// subscribed client(s).
$root->load();
return $root;
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"name": "germanairlinesva/fleet",
"type": "october-plugin",
"description": "None",
"require": {
"composer/installers": "~1.0"
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ columns:
type: text
in_use:
label: in_use
type: text
type: switch
total_miles:
label: total_miles
type: text
+1 -1
View File
@@ -14,7 +14,7 @@ columns:
valueFrom: name
only_charter:
label: only_charter
type: text
type: switch
type:
label: type
type: text
@@ -0,0 +1,31 @@
<?php namespace GermanAirlinesVa\Fleet\Updates;
use Config;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableCreateGermanAirlinesVaFleetDeferredBindings extends Migration
{
public function up()
{
Schema::connection('germanairlinesva_fleet')->create('deferred_bindings', function ($table) {
$table->engine = 'InnoDB';
$table->increments('id')->unsigned();
$table->string('master_type');
$table->string('master_field');
$table->string('slave_type');
$table->integer('slave_id');
$table->mediumText('pivot_data')->nullable();
$table->string('session_key');
$table->boolean('is_bind')->default(true);
$table->timestamps();
});
}
public function down()
{
Schema::connection('germanairlinesva_fleet')->disableForeignKeyConstraints();
Schema::connection('germanairlinesva_fleet')->dropIfExists('deferred_bindings');
Schema::connection('germanairlinesva_fleet')->enableForeignKeyConstraints();
}
}
+2
View File
@@ -1,5 +1,7 @@
1.0.1:
- 'Initialize plugin.'
- 'Create table deferred_bindings'
- builder_table_create_deferred_bindings.php
1.0.2:
- 'Created table aircraft_manufacturers'
- builder_table_create_aircraft_manufacturers.php