|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Illuminate\Database\Schema\Blueprint; |
|
4
|
|
|
use Illuminate\Database\Migrations\Migration; |
|
5
|
|
|
|
|
6
|
|
|
class CreateNavigationsTable extends Migration |
|
7
|
|
|
{ |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Run the migrations. |
|
11
|
|
|
* |
|
12
|
|
|
* @return void |
|
13
|
|
|
*/ |
|
14
|
|
|
public function up() |
|
15
|
|
|
{ |
|
16
|
|
|
Schema::create('admin_panel_navigation', function (Blueprint $table) { |
|
17
|
|
|
// These columns are needed for Baum's Nested Set implementation to work. |
|
18
|
|
|
// Column names may be changed, but they *must* all exist and be modified |
|
19
|
|
|
// in the model. |
|
20
|
|
|
// Take a look at the model scaffold comments for details. |
|
21
|
|
|
// We add indexes on parent_id, lft, rgt columns by default. |
|
22
|
|
|
$table->increments('id'); |
|
23
|
|
|
$table->integer('parent_id')->nullable()->index(); |
|
24
|
|
|
$table->integer('lft')->nullable()->index(); |
|
25
|
|
|
$table->integer('rgt')->nullable()->index(); |
|
26
|
|
|
$table->integer('depth')->nullable(); |
|
27
|
|
|
|
|
28
|
|
|
// Add needed columns here (f.ex: name, slug, path, etc.) |
|
29
|
|
|
$table->string('name'); |
|
30
|
|
|
$table->string('slug'); |
|
31
|
|
|
$table->string('icon'); |
|
32
|
|
|
$table->boolean('is_active'); |
|
33
|
|
|
|
|
34
|
|
|
$table->timestamps(); |
|
35
|
|
|
}); |
|
36
|
|
|
|
|
37
|
|
|
$root = new \Yaro\Jarboe\Models\Navigation(); |
|
38
|
|
|
$root->name = 'Root'; |
|
39
|
|
|
$root->slug = ''; |
|
40
|
|
|
$root->is_active = true; |
|
41
|
|
|
$root->icon = ''; |
|
42
|
|
|
$root->save(); |
|
43
|
|
|
|
|
44
|
|
|
$panelNode = \Yaro\Jarboe\Models\Navigation::create([ |
|
45
|
|
|
'name' => 'Admin Panel', |
|
46
|
|
|
'slug' => 'admin-panel', |
|
47
|
|
|
'icon' => 'fa-cogs', |
|
48
|
|
|
'is_active' => true, |
|
49
|
|
|
])->makeChildOf($root); |
|
50
|
|
|
|
|
51
|
|
|
\Yaro\Jarboe\Models\Navigation::create([ |
|
52
|
|
|
'name' => 'Admins', |
|
53
|
|
|
'slug' => 'admin-panel/admins', |
|
54
|
|
|
'icon' => '', |
|
55
|
|
|
'is_active' => true, |
|
56
|
|
|
])->makeChildOf($panelNode); |
|
57
|
|
|
\Yaro\Jarboe\Models\Navigation::create([ |
|
58
|
|
|
'name' => 'Roles & Permissions', |
|
59
|
|
|
'slug' => 'admin-panel/roles-and-permissions', |
|
60
|
|
|
'icon' => '', |
|
61
|
|
|
'is_active' => true, |
|
62
|
|
|
])->makeChildOf($panelNode); |
|
63
|
|
|
\Yaro\Jarboe\Models\Navigation::create([ |
|
64
|
|
|
'name' => 'Navigation', |
|
65
|
|
|
'slug' => 'admin-panel/navigation', |
|
66
|
|
|
'icon' => '', |
|
67
|
|
|
'is_active' => true, |
|
68
|
|
|
])->makeChildOf($panelNode); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Reverse the migrations. |
|
73
|
|
|
* |
|
74
|
|
|
* @return void |
|
75
|
|
|
*/ |
|
76
|
|
|
public function down() |
|
77
|
|
|
{ |
|
78
|
|
|
Schema::drop('admin_panel_navigation'); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
} |
|
82
|
|
|
|