added orderable to contacts
This commit is contained in:
parent
f4f88c9037
commit
8a2b72ca5d
|
|
@ -18,6 +18,7 @@ class ContactCrudController extends CrudController
|
||||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
||||||
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
||||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
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.
|
* Configure the CrudPanel object. Apply settings to all operations.
|
||||||
|
|
@ -84,4 +85,13 @@ class ContactCrudController extends CrudController
|
||||||
{
|
{
|
||||||
$this->setupCreateOperation();
|
$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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class AddReorderToCategoriesTable extends Migration
|
||||||
*/
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::table('exports', function (Blueprint $table) {
|
Schema::table('categories', function (Blueprint $table) {
|
||||||
$table->dropColumn('parent_id');
|
$table->dropColumn('parent_id');
|
||||||
$table->dropColumn('lft');
|
$table->dropColumn('lft');
|
||||||
$table->dropColumn('rgt');
|
$table->dropColumn('rgt');
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,6 @@ class CreateContactsTable extends Migration
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->text('name');
|
$table->text('name');
|
||||||
$table->longText('contacts');
|
$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();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue