Last active
December 14, 2015 17:29
-
-
Save crynobone/5122585 to your computer and use it in GitHub Desktop.
Creating custom installation schema during Installation for Orchestra Platform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php artisan orchestra::toolkit installer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Event::listen('orchestra.install.schema', function () | |
{ | |
/* | |
| Create a custom schema installation during Orchestra Installation. This | |
| schema will be available straight away even without activation of any | |
| extensions. | |
| | |
| Schema::create('foo', function ($table) | |
| { | |
| $table->increments('id'); | |
| $table->string('name')->default('foobar'); | |
| }); | |
| | |
*/ | |
Schema::create('posts', function ($table) | |
{ | |
$table->increments('id'); | |
$table->string('title'); | |
$table->text('content'); | |
$table->integer('user_id')->unsigned(); | |
$table->timestamps(); | |
$table->index('user_id'); | |
}); | |
}); | |
Event::listen('orchestra.install.schema: users', function ($table) | |
{ | |
/* | |
| Add custom fields on `users` table, for example you might want to add | |
| phone number, address or other useful information without the need to | |
| have additional migrations for `users` table. | |
| | |
| $table->string('phone', 20); | |
| | |
*/ | |
$table->string('username'); | |
}); | |
Event::listen('orchestra.install: user', function ($user, $input) | |
{ | |
/* | |
| For each custom fields implemented in `orchestra.install.schema: users`, | |
| you might want to add default values for the administrator account. | |
| | |
| $user->phone = '0123456789'; | |
| | |
*/ | |
// set default administrator username as admin | |
$user->username = 'admin'; | |
}); | |
Event::listen('orchestra.install: acl', function ($acl) | |
{ | |
/* | |
| Other than adding custom fields to user, you can also create additional | |
| roles and create custom acl for it. | |
| | |
| Orchestra\Model\Role::create(array('name' => 'Developer')); | |
| $acl->add_role('Developer'); | |
| $acl->add_action('manage website'); | |
| $acl->allow('Developer', 'manager website'); | |
| | |
*/ | |
$roles = array('Editor', 'Moderator'); | |
foreach ($roles as $role) | |
{ | |
Orchestra\Model\Role::create(array('name' => $role)); | |
$acl->add_role($role); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment