Deploy Ladill Woo Manager / deploy (push) Failing after 2s
Standalone app with SSO shell, WordPress plugin connect flow, webhook ingest, fulfillment inbox, and plugin activation API — no payment processing. Co-authored-by: Cursor <cursoragent@cursor.com>
64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Support\Str;
|
|
|
|
class WooStore extends Model
|
|
{
|
|
public const STATUS_PENDING = 'pending';
|
|
public const STATUS_ACTIVE = 'active';
|
|
public const STATUS_DISCONNECTED = 'disconnected';
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'public_id',
|
|
'site_url',
|
|
'site_name',
|
|
'return_url',
|
|
'webhook_secret',
|
|
'plugin_token_hash',
|
|
'status',
|
|
'connected_at',
|
|
'last_webhook_at',
|
|
'metadata',
|
|
];
|
|
|
|
protected $casts = [
|
|
'connected_at' => 'datetime',
|
|
'last_webhook_at' => 'datetime',
|
|
'metadata' => 'array',
|
|
'webhook_secret' => 'encrypted',
|
|
];
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (self $store) {
|
|
if (! $store->public_id) {
|
|
$store->public_id = (string) Str::uuid();
|
|
}
|
|
if (! $store->webhook_secret) {
|
|
$store->webhook_secret = Str::random(48);
|
|
}
|
|
});
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function orders(): HasMany
|
|
{
|
|
return $this->hasMany(WooOrder::class);
|
|
}
|
|
|
|
public function webhookUrl(): string
|
|
{
|
|
return rtrim((string) config('app.url'), '/').'/webhooks/woocommerce/'.$this->public_id;
|
|
}
|
|
}
|