refactor(webhook): remove Webhook model and related logic; add migrations to drop webhooks and kubernetes tables
This commit is contained in:
@@ -4,15 +4,12 @@ namespace App\Http\Controllers\Webhook;
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Jobs\StripeProcessJob;
|
use App\Jobs\StripeProcessJob;
|
||||||
use App\Models\Webhook;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class Stripe extends Controller
|
class Stripe extends Controller
|
||||||
{
|
{
|
||||||
protected $webhook;
|
|
||||||
|
|
||||||
public function events(Request $request)
|
public function events(Request $request)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -40,19 +37,10 @@ class Stripe extends Controller
|
|||||||
|
|
||||||
return response('Webhook received. Cool cool cool cool cool.', 200);
|
return response('Webhook received. Cool cool cool cool cool.', 200);
|
||||||
}
|
}
|
||||||
$this->webhook = Webhook::create([
|
|
||||||
'type' => 'stripe',
|
|
||||||
'payload' => $request->getContent(),
|
|
||||||
]);
|
|
||||||
StripeProcessJob::dispatch($event);
|
StripeProcessJob::dispatch($event);
|
||||||
|
|
||||||
return response('Webhook received. Cool cool cool cool cool.', 200);
|
return response('Webhook received. Cool cool cool cool cool.', 200);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->webhook->update([
|
|
||||||
'status' => 'failed',
|
|
||||||
'failure_reason' => $e->getMessage(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return response($e->getMessage(), 400);
|
return response($e->getMessage(), 400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
class Kubernetes extends BaseModel {}
|
|
@@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class Webhook extends Model
|
|
||||||
{
|
|
||||||
protected $guarded = [];
|
|
||||||
|
|
||||||
protected $casts = [
|
|
||||||
'type' => 'string',
|
|
||||||
'payload' => 'encrypted',
|
|
||||||
];
|
|
||||||
}
|
|
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('local_persistent_volumes', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('is_readonly');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('local_persistent_volumes', function (Blueprint $table) {
|
||||||
|
$table->boolean('is_readonly')->default(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('webhooks');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::create('webhooks', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->enum('status', ['pending', 'success', 'failed'])->default('pending');
|
||||||
|
$table->string('type');
|
||||||
|
$table->longText('payload');
|
||||||
|
$table->longText('failure_reason')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('kubernetes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::create('kubernetes', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('uuid')->unique();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
Reference in New Issue
Block a user