mirror of
https://github.com/cp6/my-idlers.git
synced 2024-11-16 15:33:44 +01:00
Fixed YABs, disk speed and network foreign key on delete issues
Fixed YABs, disk speed and network foreign key on delete issues
This commit is contained in:
parent
2f8db4ca24
commit
ee73ea1a31
@ -133,16 +133,9 @@ class YabsController extends Controller
|
||||
|
||||
public function destroy(Yabs $yab)
|
||||
{
|
||||
$id = $yab->id;
|
||||
$yabs = Yabs::find($id);
|
||||
$yabs = Yabs::find($yab->id);
|
||||
$yabs->delete();
|
||||
|
||||
$disk = DiskSpeed::find($id);
|
||||
$disk->delete();
|
||||
|
||||
$network = NetworkSpeed::find($id);
|
||||
$network->delete();
|
||||
|
||||
$update_server = DB::table('servers')
|
||||
->where('id', $yab->server_id)
|
||||
->update(['has_yabs' => 0]);
|
||||
|
@ -37,7 +37,7 @@ class AddForeignKeys extends Migration
|
||||
});
|
||||
|
||||
Schema::table('yabs', function (Blueprint $table) {
|
||||
$table->foreign('server_id', 'yabs_fk_servers')->references('id')->on('servers');
|
||||
$table->foreign('server_id', 'yabs_fk_servers')->references('id')->on('servers')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::table('disk_speed', function (Blueprint $table) {
|
||||
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('disk_speed', function (Blueprint $table) {
|
||||
$table->dropForeign('ds_fk_yabs');
|
||||
|
||||
$table->foreign('id', 'ds_fk_yabs')->references('id')->on('yabs')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::table('network_speed', function (Blueprint $table) {
|
||||
$table->dropForeign('ns_fk_yabs');
|
||||
|
||||
$table->foreign('id', 'ns_fk_yabs')->references('id')->on('yabs')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user