added orderable to contacts

This commit is contained in:
Amanmyrat 2022-12-06 11:15:35 +05:00
parent f4f88c9037
commit 8a2b72ca5d
4 changed files with 51 additions and 5 deletions

View File

@ -18,6 +18,7 @@ class ContactCrudController extends CrudController
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ReorderOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
@ -84,4 +85,13 @@ class ContactCrudController extends CrudController
{
$this->setupCreateOperation();
}
protected function setupReorderOperation()
{
// define which model attribute will be shown on draggable elements
$this->crud->set('reorder.label', 'title');
// define how deep the admin is allowed to nest the items
// for infinite levels, set it to 0
$this->crud->set('reorder.max_level', 1);
}
}

View File

@ -28,7 +28,7 @@ class AddReorderToCategoriesTable extends Migration
*/
public function down()
{
Schema::table('exports', function (Blueprint $table) {
Schema::table('categories', function (Blueprint $table) {
$table->dropColumn('parent_id');
$table->dropColumn('lft');
$table->dropColumn('rgt');

View File

@ -17,10 +17,6 @@ class CreateContactsTable extends Migration
$table->id();
$table->text('name');
$table->longText('contacts');
$table->integer('parent_id')->default(0)->nullable();
$table->integer('lft')->default(0);
$table->integer('rgt')->default(0);
$table->integer('depth')->default(0);
$table->timestamps();
});
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddReorderToContactsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('contacts', function (Blueprint $table) {
$table->after('contacts', function ($table) {
$table->integer('parent_id')->default(0)->nullable();
$table->integer('lft')->default(0);
$table->integer('rgt')->default(0);
$table->integer('depth')->default(0);
});
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('contacts', function (Blueprint $table) {
$table->dropColumn('parent_id');
$table->dropColumn('lft');
$table->dropColumn('rgt');
$table->dropColumn('depth');
});
}
}