update
This commit is contained in:
@@ -71,7 +71,7 @@ class Datastore extends Controller
|
||||
public function edit(int $id = 0)
|
||||
{
|
||||
$datastore = $this->datastoreRepository->findWithRelationships($id, ['host.datacenter']);
|
||||
|
||||
|
||||
if (!$datastore) {
|
||||
return back()->withErrors('Invalid Request');
|
||||
}
|
||||
|
||||
@@ -40,11 +40,16 @@ class DatastoreRepository extends BaseRepository implements DatastoreRepositoryI
|
||||
{
|
||||
$model = $this->model;
|
||||
if (count($relationships) > 0) {
|
||||
$validRelationships = [];
|
||||
foreach ($relationships as $relationship) {
|
||||
if (method_exists($model, $relationship)) {
|
||||
$model = $model->with($relationship);
|
||||
$firstRelation = explode('.', $relationship)[0];
|
||||
if (method_exists($model, $firstRelation)) {
|
||||
$validRelationships[] = $relationship;
|
||||
}
|
||||
}
|
||||
if (count($validRelationships) > 0) {
|
||||
$model = $model->with($validRelationships);
|
||||
}
|
||||
}
|
||||
|
||||
// Xử lý withCount
|
||||
|
||||
@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
@@ -13,13 +12,13 @@ return new class extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('module_datastore',function (Blueprint $table) {
|
||||
Schema::create('module_datastore', function (Blueprint $table) {
|
||||
$table->id()->autoIncrement();
|
||||
$table->string('name',255)->nullable();
|
||||
$table->string('datastore',255)->nullable();
|
||||
$table->string('type',100)->nullable();
|
||||
$table->string('name', 255)->nullable();
|
||||
$table->string('datastore', 255)->nullable();
|
||||
$table->string('type', 100)->nullable();
|
||||
$table->integer('space')->nullable();
|
||||
$table->bigInteger('module_host_id')->default(0)->index();
|
||||
$table->foreignId('module_host_id')->index()->constrained('module_hosts')->cascadeOnDelete();
|
||||
$table->tinyInteger('status')->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
@@ -32,6 +31,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('module_datastores');
|
||||
Schema::dropIfExists('module_datastore');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('module_datastore', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('module_host_id')->default(0)->change();
|
||||
});
|
||||
|
||||
Schema::table('module_datastore', function (Blueprint $table) {
|
||||
$table->foreign('module_host_id')
|
||||
->references('id')
|
||||
->on('module_host')
|
||||
->cascadeOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('module_datastore', function (Blueprint $table) {
|
||||
$table->dropForeign(['module_host_id']);
|
||||
});
|
||||
|
||||
Schema::table('module_datastore', function (Blueprint $table) {
|
||||
$table->bigInteger('module_host_id')->default(0)->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -52,11 +52,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row form-group align-items-center mb-0">
|
||||
<label for="space" class="col-md-3 text-right">Status</label>
|
||||
<label for="status" class="col-md-3 text-right">Status</label>
|
||||
<div class="col-md-9 p-1 bg-customer">
|
||||
<select class="custom-select" name="status">
|
||||
<option value="1">Active</option>
|
||||
<option value="0">No Active</option>
|
||||
<select class="form-control select2 single__select" name="status" id="status">
|
||||
<option value="1" selected>✓ Active</option>
|
||||
<option value="0">✗ Inactive</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -56,11 +56,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row form-group align-items-center mb-0">
|
||||
<label for="space" class="col-md-3 text-right">Status</label>
|
||||
<label for="status" class="col-md-3 text-right">Status</label>
|
||||
<div class="col-md-9 p-1 bg-customer">
|
||||
<select class="custom-select" name="status">
|
||||
<option value="1" @selected($datastore->status === 1)>Active</option>
|
||||
<option value="0" @selected($datastore->status === 0)>No Active</option>
|
||||
<select class="form-control select2 single__select" name="status" id="status">
|
||||
<option value="1" @selected($datastore->status === 1)>✓ Active</option>
|
||||
<option value="0" @selected($datastore->status === 0)>✗ Inactive</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user