yoco updated to use webhook
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AppSetting extends Model
|
||||
{
|
||||
protected $fillable = ['key', 'value', 'type', 'description'];
|
||||
|
||||
/**
|
||||
* Get a setting by key
|
||||
*/
|
||||
public static function get(string $key, mixed $default = null): mixed
|
||||
{
|
||||
$setting = self::where('key', $key)->first();
|
||||
|
||||
if (!$setting) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return match ($setting->type) {
|
||||
'integer' => (int) $setting->value,
|
||||
'boolean' => (bool) $setting->value,
|
||||
'json' => json_decode($setting->value, true),
|
||||
default => $setting->value,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a setting
|
||||
*/
|
||||
public static function set(string $key, mixed $value, string $type = 'string'): void
|
||||
{
|
||||
self::updateOrCreate(
|
||||
['key' => $key],
|
||||
['value' => is_array($value) ? json_encode($value) : (string) $value, 'type' => $type]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class CustomOrder extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'uuid',
|
||||
'order_number',
|
||||
'type',
|
||||
'status',
|
||||
'design_fee',
|
||||
'library_discount_applied',
|
||||
'material_cost',
|
||||
'total_cost',
|
||||
'deposit_amount',
|
||||
'balance_amount',
|
||||
'deposit_status',
|
||||
'balance_status',
|
||||
'customer_brief',
|
||||
'admin_notes',
|
||||
'submitted_at',
|
||||
'approved_at',
|
||||
'rejected_at',
|
||||
'completed_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'library_discount_applied' => 'boolean',
|
||||
'design_fee' => 'decimal:2',
|
||||
'material_cost' => 'decimal:2',
|
||||
'total_cost' => 'decimal:2',
|
||||
'deposit_amount' => 'decimal:2',
|
||||
'balance_amount' => 'decimal:2',
|
||||
'submitted_at' => 'datetime',
|
||||
'approved_at' => 'datetime',
|
||||
'rejected_at' => 'datetime',
|
||||
'completed_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Boot method for model
|
||||
*/
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
$model->uuid = \Illuminate\Support\Str::uuid();
|
||||
$model->order_number = 'CUSTOM-' . now()->format('Ymd') . '-' . strtoupper(uniqid());
|
||||
$model->submitted_at = now();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user that owns this custom order
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the specifications for this custom order
|
||||
*/
|
||||
public function specifications(): HasOne
|
||||
{
|
||||
return $this->hasOne(CustomOrderSpecification::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the files uploaded for this custom order
|
||||
*/
|
||||
public function files(): HasMany
|
||||
{
|
||||
return $this->hasMany(CustomOrderFile::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the proofs uploaded for this custom order
|
||||
*/
|
||||
public function proofs(): HasMany
|
||||
{
|
||||
return $this->hasMany(CustomOrderProof::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get route key name for implicit route binding
|
||||
*/
|
||||
public function getRouteKeyName()
|
||||
{
|
||||
return 'uuid';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CustomOrderFile extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'custom_order_id',
|
||||
'file_type',
|
||||
'file_path',
|
||||
'original_filename',
|
||||
'file_size',
|
||||
'mime_type',
|
||||
'uploaded_by',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the custom order that owns this file
|
||||
*/
|
||||
public function customOrder(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CustomOrder::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user who uploaded this file
|
||||
*/
|
||||
public function uploadedByUser(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'uploaded_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CustomOrderProof extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'custom_order_id',
|
||||
'file_path',
|
||||
'original_filename',
|
||||
'file_size',
|
||||
'mime_type',
|
||||
'notes',
|
||||
'uploaded_by',
|
||||
'status',
|
||||
'rejection_reason',
|
||||
'approved_at',
|
||||
'rejected_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'approved_at' => 'datetime',
|
||||
'rejected_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the custom order that owns this proof
|
||||
*/
|
||||
public function customOrder(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CustomOrder::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the admin who uploaded this proof
|
||||
*/
|
||||
public function uploadedByUser(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'uploaded_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CustomOrderSpecification extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'custom_order_id',
|
||||
'length',
|
||||
'width',
|
||||
'height',
|
||||
'print_stock_id',
|
||||
'quantity',
|
||||
'special_instructions',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'length' => 'decimal:2',
|
||||
'width' => 'decimal:2',
|
||||
'height' => 'decimal:2',
|
||||
'quantity' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the custom order that owns this specification
|
||||
*/
|
||||
public function customOrder(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CustomOrder::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the print stock
|
||||
*/
|
||||
public function printStock(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PrintStock::class);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,11 @@ class Order extends Model
|
||||
'customer_email',
|
||||
'customer_phone',
|
||||
'shipping_address',
|
||||
'notes'
|
||||
'notes',
|
||||
'yoco_checkout_id',
|
||||
'yoco_redirect_url',
|
||||
'yoco_checkout_response',
|
||||
'yoco_payment_id',
|
||||
];
|
||||
|
||||
public function user()
|
||||
|
||||
@@ -22,6 +22,8 @@ class User extends Authenticatable
|
||||
'email',
|
||||
'password',
|
||||
'is_admin',
|
||||
'google_id',
|
||||
'email_verified_at',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user