fix service cant show
This commit is contained in:
@@ -17,6 +17,15 @@ class Service extends Model
|
|||||||
return ['uuid'];
|
return ['uuid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function booted(): void
|
||||||
|
{
|
||||||
|
static::saving(function (Service $service) {
|
||||||
|
if ($service->type === null && $service->product_id) {
|
||||||
|
$service->type = Product::query()->where('id', $service->product_id)->value('product_type');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected $table = 'services';
|
protected $table = 'services';
|
||||||
|
|
||||||
public const HOSTING_ACCOUNT_RELATIONS = [
|
public const HOSTING_ACCOUNT_RELATIONS = [
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
DB::statement(<<<'SQL'
|
||||||
|
UPDATE services
|
||||||
|
JOIN products ON products.id = services.product_id
|
||||||
|
SET services.type = products.product_type
|
||||||
|
WHERE services.type IS NULL
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user